Changeset 251537 in webkit
- Timestamp:
- Oct 24, 2019, 7:39:09 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251536 r251537 1 2019-10-24 Chris Dumez <[email protected]> 2 3 AudioContext should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203102 5 6 Reviewed by Geoffrey Garen. 7 8 Update layout test coverage. 9 10 * fast/history/page-cache-running-audiocontext-expected.txt: 11 * fast/history/page-cache-running-audiocontext.html: 12 1 13 2019-10-24 Antoine Quint <[email protected]> 2 14 -
trunk/LayoutTests/fast/history/page-cache-running-audiocontext-expected.txt
r180934 r251537 1 Tests that a page with a running AudioContext does not go into the pagecache.1 Tests that a page with a running AudioContext goes into the back/forward cache. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 5 5 6 6 pageshow - not from cache 7 PASS Page was not restored from page cache 7 pagehide - entering cache 8 pageshow - from cache 9 PASS Page did enter and was restored from the back/forward cache 8 10 PASS successfullyParsed is true 9 11 -
trunk/LayoutTests/fast/history/page-cache-running-audiocontext.html
r251220 r251537 3 3 <html> 4 4 <body> 5 <script src="../../resources/js-test -pre.js"></script>5 <script src="../../resources/js-test.js"></script> 6 6 <script> 7 description('Tests that a page with a running AudioContext does not go into the pagecache.');7 description('Tests that a page with a running AudioContext goes into the back/forward cache.'); 8 8 window.jsTestIsAsync = true; 9 9 … … 11 11 debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache"); 12 12 13 if (!window.sessionStorage.page_cache_running_audiocontext_test_started) 14 return; 15 16 delete window.sessionStorage.page_cache_running_audiocontext_test_started; 17 18 if (event.persisted) 19 testFailed("Page did enter and was restored from the page cache"); 20 else 21 testPassed("Page was not restored from page cache"); 22 23 finishJSTest(); 13 if (event.persisted) { 14 testPassed("Page did enter and was restored from the back/forward cache"); 15 finishJSTest(); 16 } 24 17 }, false); 25 18 26 19 window.addEventListener("pagehide", function(event) { 27 20 debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache"); 28 if ( event.persisted) {29 testFailed("Page entered the pagecache.");21 if (!event.persisted) { 22 testFailed("Page failed to enter the back/forward cache."); 30 23 finishJSTest(); 31 24 } … … 43 36 setTimeout(function() { 44 37 // Force a back navigation back to this page. 45 window.sessionStorage.page_cache_running_audiocontext_test_started = true;46 38 window.location.href = "resources/page-cache-helper.html"; 47 39 }, 0); 48 40 }, false); 49 50 41 </script> 51 <script src="../../resources/js-test-post.js"></script>52 42 </body> 53 43 </html> -
trunk/Source/WebCore/ChangeLog
r251532 r251537 1 2019-10-24 Chris Dumez <[email protected]> 2 3 AudioContext should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203102 5 6 Reviewed by Geoffrey Garen. 7 8 Allow pages with AudioContexts that are rendering in the back/forward cache. 9 Upon entering the back/forward cache, we suspend rendering and update IsPlaying 10 state so that the browser no longer shows the "Audio Playing" icon. Upon restoring 11 from the back/forward cache, we resume rendering and update IsPlaying state again 12 so that the browser shows the "Audio Playing" icon again. I tested it on: 13 - http://webaudioplayground.appspot.com 14 15 With regards to events dispatching, the AudioContext class is already using a 16 GenericEventQueue that properly delays event dispatching while in the back/forward 17 cache. 18 19 No new tests, updated existing test. 20 21 * Modules/webaudio/AudioContext.cpp: 22 (WebCore::AudioContext::suspend): 23 (WebCore::AudioContext::resume): 24 (WebCore::AudioContext::suspendRendering): 25 (WebCore::AudioContext::resumeRendering): 26 * Modules/webaudio/AudioContext.h: 27 * Modules/webaudio/AudioContext.idl: 28 1 29 2019-10-24 Antti Koivisto <[email protected]> 2 30 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp
r251244 r251537 341 341 } 342 342 343 bool AudioContext::shouldPreventEnteringBackForwardCache_DEPRECATED() const 344 { 345 // FIXME: We should be able to suspend while rendering as well with some more code. 346 return m_state != State::Suspended && m_state != State::Closed; 343 void AudioContext::suspend(ReasonForSuspension) 344 { 345 if (state() == State::Running) { 346 m_mediaSession->beginInterruption(PlatformMediaSession::PlaybackSuspended); 347 document()->updateIsPlayingMedia(); 348 } 349 } 350 351 void AudioContext::resume() 352 { 353 if (state() == State::Interrupted) { 354 m_mediaSession->endInterruption(PlatformMediaSession::MayResumePlaying); 355 document()->updateIsPlayingMedia(); 356 } 347 357 } 348 358 … … 1230 1240 } 1231 1241 1232 void AudioContext::suspend (DOMPromiseDeferred<void>&& promise)1242 void AudioContext::suspendRendering(DOMPromiseDeferred<void>&& promise) 1233 1243 { 1234 1244 if (isOfflineContext() || m_isStopScheduled) { … … 1259 1269 } 1260 1270 1261 void AudioContext::resume (DOMPromiseDeferred<void>&& promise)1271 void AudioContext::resumeRendering(DOMPromiseDeferred<void>&& promise) 1262 1272 { 1263 1273 if (isOfflineContext() || m_isStopScheduled) { -
trunk/Source/WebCore/Modules/webaudio/AudioContext.h
r251244 r251537 127 127 AudioListener* listener() { return m_listener.get(); } 128 128 129 using ActiveDOMObject::suspend; 130 using ActiveDOMObject::resume; 131 132 void suspend(DOMPromiseDeferred<void>&&); 133 void resume(DOMPromiseDeferred<void>&&); 129 void suspendRendering(DOMPromiseDeferred<void>&&); 130 void resumeRendering(DOMPromiseDeferred<void>&&); 134 131 void close(DOMPromiseDeferred<void>&&); 135 132 … … 339 336 340 337 // ActiveDOMObject API. 338 void suspend(ReasonForSuspension) final; 339 void resume() final; 341 340 void stop() override; 342 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;343 341 const char* activeDOMObjectName() const override; 344 342 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.idl
r244825 r251537 52 52 readonly attribute AudioListener listener; 53 53 54 Promise<void> suspend();55 Promise<void> resume();54 [ImplementedAs=suspendRendering] Promise<void> suspend(); 55 [ImplementedAs=resumeRendering] Promise<void> resume(); 56 56 Promise<void> close(); 57 57
Note:
See TracChangeset
for help on using the changeset viewer.