Changeset 291267 in webkit
- Timestamp:
- Mar 15, 2022 12:19:08 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webaudio/silent-audio-interrupted-in-background-expected.txt (modified) (2 diffs)
-
LayoutTests/webaudio/silent-audio-interrupted-in-background.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/webaudio/AudioContext.cpp (modified) (6 diffs)
-
Source/WebCore/Modules/webaudio/AudioContext.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291266 r291267 1 2022-03-15 Youenn Fablet <youenn@apple.com> 2 3 AudioContext stops playing when minimizing or moving the macOS Safari window to the background. 4 https://bugs.webkit.org/show_bug.cgi?id=231105 5 <rdar://problem/83889697> 6 7 Reviewed by Eric Carlson. 8 9 Use internals API to be working on iOS as well (this does not trigger enterBackground code path). 10 11 * webaudio/silent-audio-interrupted-in-background-expected.txt: 12 * webaudio/silent-audio-interrupted-in-background.html: 13 1 14 2022-03-14 Lauro Moura <lmoura@igalia.com> 2 15 -
trunk/LayoutTests/webaudio/silent-audio-interrupted-in-background-expected.txt
r214721 r291267 1 Tests that silent WebAudio rendering gets interruptedin hidden pages.1 Tests silent WebAudio rendering in hidden pages. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 6 6 PASS context.state became 'running' 7 7 * Setting page visibility to hidden 8 PASS context.state became 'interrupted' 8 PASS document.hidden is true 9 PASS context.state is 'running' 9 10 * Setting page visibility to visible 10 PASS context.state became 'running' 11 PASS document.hidden is false 12 PASS context.state is 'running' 11 13 PASS successfullyParsed is true 12 14 -
trunk/LayoutTests/webaudio/silent-audio-interrupted-in-background.html
r267504 r291267 4 4 <script src="../resources/js-test-pre.js"></script> 5 5 <script> 6 description("Tests that silent WebAudio rendering gets interruptedin hidden pages.");6 description("Tests silent WebAudio rendering in hidden pages."); 7 7 jsTestIsAsync = true; 8 8 9 document.onvisibilitychange = function() { 10 if (document.hidden) { 11 shouldBecomeEqual("context.state", "'interrupted'", showPage); 12 } else { 13 shouldBecomeEqual("context.state", "'running'", finishJSTest); 9 let counter = 0; 10 document.onvisibilitychange = async function() { 11 if (!counter) { 12 counter = 1; 13 shouldBeTrue("document.hidden"); 14 shouldBe("context.state", "'running'"); 15 showPage(); 16 return; 14 17 } 18 shouldBeFalse("document.hidden"); 19 shouldBe("context.state", "'running'"); 20 finishJSTest(); 15 21 } 16 22 … … 18 24 { 19 25 debug("* Setting page visibility to visible"); 20 if (window. testRunner)21 testRunner.setPageVisibility("visible");26 if (window.internals) 27 internals.setPageVisibility(true); 22 28 } 23 29 … … 25 31 { 26 32 debug("* Setting page visibility to hidden"); 27 if (window. testRunner)28 testRunner.setPageVisibility("hidden");33 if (window.internals) 34 internals.setPageVisibility(false); 29 35 } 30 36 -
trunk/Source/WebCore/ChangeLog
r291261 r291267 1 2022-03-15 Youenn Fablet <youenn@apple.com> 2 3 AudioContext stops playing when minimizing or moving the macOS Safari window to the background. 4 https://bugs.webkit.org/show_bug.cgi?id=231105 5 <rdar://problem/83889697> 6 7 Reviewed by Eric Carlson. 8 9 AudioContext was stopped when minimizing windows if not playing audio as a way to reduce CPU usage. 10 But this is visible to users (if AudioContext produces audio through a track) or to web pages (use of audio worklet or script processor node). 11 Remove that code. 12 Small refactoring to remove isOfflineContext checks that can only be false in AudioContext. 13 14 Covered by existing tests. 15 16 * Modules/webaudio/AudioContext.cpp: 17 * Modules/webaudio/AudioContext.h: 18 1 19 2022-03-14 Wenson Hsieh <wenson_hsieh@apple.com> 2 20 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp
r286918 r291267 123 123 124 124 document.addAudioProducer(*this); 125 document.registerForVisibilityStateChangedCallbacks(*this);126 125 127 126 // Unlike OfflineAudioContext, AudioContext does not require calling resume() to start rendering. … … 149 148 AudioContext::~AudioContext() 150 149 { 151 if (!isOfflineContext() && scriptExecutionContext()) { 152 document()->removeAudioProducer(*this); 153 document()->unregisterForVisibilityStateChangedCallbacks(*this); 154 } 150 if (auto* document = this->document()) 151 document->removeAudioProducer(*this); 155 152 } 156 153 … … 194 191 void AudioContext::close(DOMPromiseDeferred<void>&& promise) 195 192 { 196 if (is OfflineContext() || isStopped()) {193 if (isStopped()) { 197 194 promise.reject(InvalidStateError); 198 195 return; … … 217 214 void AudioContext::suspendRendering(DOMPromiseDeferred<void>&& promise) 218 215 { 219 if (isOfflineContext()) {220 promise.reject(Exception { InvalidStateError, "Cannot call suspend() on an OfflineAudioContext"_s });221 return;222 }223 224 216 if (isStopped() || state() == State::Closed) { 225 217 promise.reject(Exception { InvalidStateError, "Context is closed"_s }); … … 248 240 void AudioContext::resumeRendering(DOMPromiseDeferred<void>&& promise) 249 241 { 250 if (isOfflineContext()) {251 promise.reject(Exception { InvalidStateError, "Cannot call resume() on an OfflineAudioContext"_s });252 return;253 }254 255 242 if (isStopped() || state() == State::Closed) { 256 243 promise.reject(Exception { InvalidStateError, "Context is closed"_s }); … … 417 404 } 418 405 419 void AudioContext::visibilityStateChanged()420 {421 // Do not suspend if audio is audible.422 if (!document() || mediaState() == MediaProducerMediaState::IsPlayingAudio || isStopped())423 return;424 425 if (document()->hidden()) {426 if (state() == State::Running) {427 ALWAYS_LOG(LOGIDENTIFIER, "Suspending playback after going to the background");428 m_mediaSession->beginInterruption(PlatformMediaSession::EnteringBackground);429 }430 } else {431 if (state() == State::Interrupted) {432 ALWAYS_LOG(LOGIDENTIFIER, "Resuming playback after entering foreground");433 m_mediaSession->endInterruption(PlatformMediaSession::MayResumePlaying);434 }435 }436 }437 438 406 void AudioContext::suspend(ReasonForSuspension) 439 407 { -
trunk/Source/WebCore/Modules/webaudio/AudioContext.h
r284173 r291267 31 31 #include "MediaProducer.h" 32 32 #include "PlatformMediaSession.h" 33 #include "VisibilityChangeClient.h"34 33 #include <wtf/UniqueRef.h> 35 34 … … 49 48 , public MediaProducer 50 49 , public MediaCanStartListener 51 , private PlatformMediaSessionClient 52 , private VisibilityChangeClient { 50 , private PlatformMediaSessionClient { 53 51 WTF_MAKE_ISO_ALLOCATED(AudioContext); 54 52 public: … … 137 135 void mediaCanStart(Document&) final; 138 136 139 // VisibilityChangeClient140 void visibilityStateChanged() final;141 142 137 // ActiveDOMObject 143 138 const char* activeDOMObjectName() const final;
Note: See TracChangeset
for help on using the changeset viewer.