Changeset 231817 in webkit
- Timestamp:
- May 15, 2018, 4:01:14 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/LayoutTests/ChangeLog ¶
r231813 r231817 1 2018-05-15 Jer Noble <jer.noble@apple.com> 2 3 Media continues loading after rendered invisible (removed from DOM; scrolled off screen) 4 https://bugs.webkit.org/show_bug.cgi?id=185487 5 6 Reviewed by Eric Carlson. 7 8 * media/video-buffering-allowed-expected.txt: Added. 9 * media/video-buffering-allowed.html: Added. 10 * media/video-test.js: 11 (compare): 12 (testExpected): 13 (sleepFor): 14 (testArraysEqual): Deleted. 15 1 16 2018-05-15 Charles Vazac <cvazac@gmail.com> 2 17 -
TabularUnified trunk/LayoutTests/media/media-source/only-bcp47-language-tags-accepted-as-valid-expected.txt ¶
r210280 r231817 1 CONSOLE MESSAGE: line 176: The language 'a' is not a valid BCP 47 language tag.1 CONSOLE MESSAGE: line 221: The language 'a' is not a valid BCP 47 language tag. 2 2 CONSOLE MESSAGE: line 106: The language 'a' is not a valid BCP 47 language tag. 3 CONSOLE MESSAGE: line 176: The language 'a' is not a valid BCP 47 language tag.4 CONSOLE MESSAGE: line 176: The language '1' is not a valid BCP 47 language tag.3 CONSOLE MESSAGE: line 221: The language 'a' is not a valid BCP 47 language tag. 4 CONSOLE MESSAGE: line 221: The language '1' is not a valid BCP 47 language tag. 5 5 CONSOLE MESSAGE: line 106: The language '1' is not a valid BCP 47 language tag. 6 CONSOLE MESSAGE: line 176: The language '1' is not a valid BCP 47 language tag.7 CONSOLE MESSAGE: line 176: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag.6 CONSOLE MESSAGE: line 221: The language '1' is not a valid BCP 47 language tag. 7 CONSOLE MESSAGE: line 221: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 8 8 CONSOLE MESSAGE: line 106: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 9 CONSOLE MESSAGE: line 176: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag.10 CONSOLE MESSAGE: line 176: The language '1a' is not a valid BCP 47 language tag.9 CONSOLE MESSAGE: line 221: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 10 CONSOLE MESSAGE: line 221: The language '1a' is not a valid BCP 47 language tag. 11 11 CONSOLE MESSAGE: line 106: The language '1a' is not a valid BCP 47 language tag. 12 CONSOLE MESSAGE: line 176: The language '1a' is not a valid BCP 47 language tag.13 CONSOLE MESSAGE: line 176: The language '-a' is not a valid BCP 47 language tag.12 CONSOLE MESSAGE: line 221: The language '1a' is not a valid BCP 47 language tag. 13 CONSOLE MESSAGE: line 221: The language '-a' is not a valid BCP 47 language tag. 14 14 CONSOLE MESSAGE: line 106: The language '-a' is not a valid BCP 47 language tag. 15 CONSOLE MESSAGE: line 176: The language '-a' is not a valid BCP 47 language tag.16 CONSOLE MESSAGE: line 176: The language 'a-' is not a valid BCP 47 language tag.15 CONSOLE MESSAGE: line 221: The language '-a' is not a valid BCP 47 language tag. 16 CONSOLE MESSAGE: line 221: The language 'a-' is not a valid BCP 47 language tag. 17 17 CONSOLE MESSAGE: line 106: The language 'a-' is not a valid BCP 47 language tag. 18 CONSOLE MESSAGE: line 176: The language 'a-' is not a valid BCP 47 language tag.19 CONSOLE MESSAGE: line 176: The language 'a1' is not a valid BCP 47 language tag.18 CONSOLE MESSAGE: line 221: The language 'a-' is not a valid BCP 47 language tag. 19 CONSOLE MESSAGE: line 221: The language 'a1' is not a valid BCP 47 language tag. 20 20 CONSOLE MESSAGE: line 106: The language 'a1' is not a valid BCP 47 language tag. 21 CONSOLE MESSAGE: line 176: The language 'a1' is not a valid BCP 47 language tag.22 CONSOLE MESSAGE: line 176: The language 'aa1' is not a valid BCP 47 language tag.21 CONSOLE MESSAGE: line 221: The language 'a1' is not a valid BCP 47 language tag. 22 CONSOLE MESSAGE: line 221: The language 'aa1' is not a valid BCP 47 language tag. 23 23 CONSOLE MESSAGE: line 106: The language 'aa1' is not a valid BCP 47 language tag. 24 CONSOLE MESSAGE: line 176: The language 'aa1' is not a valid BCP 47 language tag.25 CONSOLE MESSAGE: line 176: The language 'aaaa' is not a valid BCP 47 language tag.24 CONSOLE MESSAGE: line 221: The language 'aa1' is not a valid BCP 47 language tag. 25 CONSOLE MESSAGE: line 221: The language 'aaaa' is not a valid BCP 47 language tag. 26 26 CONSOLE MESSAGE: line 106: The language 'aaaa' is not a valid BCP 47 language tag. 27 CONSOLE MESSAGE: line 176: The language 'aaaa' is not a valid BCP 47 language tag.28 CONSOLE MESSAGE: line 176: The language 'aaa1' is not a valid BCP 47 language tag.27 CONSOLE MESSAGE: line 221: The language 'aaaa' is not a valid BCP 47 language tag. 28 CONSOLE MESSAGE: line 221: The language 'aaa1' is not a valid BCP 47 language tag. 29 29 CONSOLE MESSAGE: line 106: The language 'aaa1' is not a valid BCP 47 language tag. 30 CONSOLE MESSAGE: line 176: The language 'aaa1' is not a valid BCP 47 language tag.31 CONSOLE MESSAGE: line 176: The language 'inv-alid-char space' is not a valid BCP 47 language tag.30 CONSOLE MESSAGE: line 221: The language 'aaa1' is not a valid BCP 47 language tag. 31 CONSOLE MESSAGE: line 221: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 32 32 CONSOLE MESSAGE: line 106: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 33 CONSOLE MESSAGE: line 176: The language 'inv-alid-char space' is not a valid BCP 47 language tag.34 CONSOLE MESSAGE: line 176: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag.33 CONSOLE MESSAGE: line 221: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 34 CONSOLE MESSAGE: line 221: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 35 35 CONSOLE MESSAGE: line 106: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 36 CONSOLE MESSAGE: line 176: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag.37 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag.36 CONSOLE MESSAGE: line 221: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 37 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 38 38 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 39 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag.40 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-*' is not a valid BCP 47 language tag.39 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 40 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 41 41 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 42 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-*' is not a valid BCP 47 language tag.43 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-' is not a valid BCP 47 language tag.42 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 43 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 44 44 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 45 CONSOLE MESSAGE: line 176: The language 'inv-alid-char-' is not a valid BCP 47 language tag.45 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 46 46 Test that only BCP47 language tags are accepted as valid but still reflected. 47 47 -
TabularUnified trunk/LayoutTests/media/video-test.js ¶
r225265 r231817 63 63 } 64 64 65 function testExpected(testFuncString, expected, comparison) 66 { 67 try { 68 var observed = eval(testFuncString); 69 } catch (ex) { 70 consoleWrite(ex); 71 return; 72 } 73 74 if (comparison === undefined) 75 comparison = '=='; 65 function compare(testFuncString, expected, comparison) 66 { 67 var observed = eval(testFuncString); 76 68 77 69 var success = false; … … 88 80 } 89 81 90 reportExpected(success, testFuncString, comparison, expected, observed) 82 return {success:success, observed:observed}; 83 } 84 85 function testExpected(testFuncString, expected, comparison) 86 { 87 if (comparison === undefined) 88 comparison = '=='; 89 90 try { 91 let {success, observed} = compare(testFuncString, expected, comparison); 92 reportExpected(success, testFuncString, comparison, expected, observed) 93 } catch (ex) { 94 consoleWrite(ex); 95 } 96 } 97 98 function sleepFor(duration) { 99 return new Promise(resolve => { 100 setTimeout(resolve, duration); 101 }); 102 } 103 104 function testExpectedEventually(testFuncString, expected, comparison) 105 { 106 return new Promise(async resolve => { 107 var success; 108 var observed; 109 if (comparison === undefined) 110 comparison = '=='; 111 while (true) { 112 try { 113 let {success, observed} = compare(testFuncString, expected, comparison); 114 if (success) { 115 reportExpected(success, testFuncString, comparison, expected, observed); 116 resolve(); 117 return; 118 } 119 await sleepFor(1); 120 } catch (ex) { 121 consoleWrite(ex); 122 resolve(); 123 return; 124 } 125 } 126 }); 91 127 } 92 128 … … 149 185 consoleWrite(ex); 150 186 } 187 } 188 189 function waitFor(element, event) { 190 return new Promise(resolve => { 191 element.addEventListener(event, event => { 192 consoleWrite(`EVENT(${event.type})`); 193 resolve(event); 194 }, { once: true }); 195 }); 151 196 } 152 197 -
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r231813 r231817 1 2018-05-15 Jer Noble <jer.noble@apple.com> 2 3 Media continues loading after rendered invisible (removed from DOM; scrolled off screen) 4 https://bugs.webkit.org/show_bug.cgi?id=185487 5 6 Reviewed by Eric Carlson. 7 8 Test: media/video-buffering-allowed.html 9 10 When a media element is removed from the dom (e.g. through innerHTML=""), it doesn't 11 necessarily stop loading media data; it will continue to do so until its destructor is 12 called through garbage collection. Similarly, when a media element is rendered not-visible 13 by being scrolled off-screen or being made display:none, media loading continues. There 14 are legitimate use cases for out-of-DOM media loading, so only temporarily block loading 15 when the element transitions out of the document. Similarly, only block loading for non-visible 16 media elements when returning from the "page is hidden" state, and only until the media 17 element is asked to play or is otherwise made visible. 18 19 Note: this refactors a lot of code out of PlatformMediaSession and into MediaElementSession, 20 since this code is specific to "media elements". 21 22 * html/HTMLMediaElement.cpp: 23 (WebCore::HTMLMediaElement::HTMLMediaElement): 24 (WebCore::HTMLMediaElement::insertedIntoAncestor): 25 (WebCore::HTMLMediaElement::removedFromAncestor): 26 (WebCore::HTMLMediaElement::playInternal): 27 (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer): 28 (WebCore::HTMLMediaElement::resume): 29 (WebCore::HTMLMediaElement::visibilityStateChanged): 30 (WebCore::HTMLMediaElement::createMediaPlayer): 31 (WebCore::HTMLMediaElement::setShouldBufferData): 32 (WebCore::HTMLMediaElement::purgeBufferedDataIfPossible): 33 (WebCore::HTMLMediaElement::isVisibleInViewportChanged): 34 (WebCore::HTMLMediaElement::fullscreenModeChanged): 35 (WebCore::HTMLMediaElement::setInActiveDocument): 36 * html/HTMLMediaElement.h: 37 (WebCore::HTMLMediaElement::shouldBufferData const): 38 (WebCore::HTMLMediaElement::elementIsHidden const): 39 * html/MediaElementSession.cpp: 40 (WebCore::MediaElementSession::MediaElementSession): 41 (WebCore::MediaElementSession::clientWillBeginAutoplaying): 42 (WebCore::MediaElementSession::clientWillBeginPlayback): 43 (WebCore::MediaElementSession::clientWillPausePlayback): 44 (WebCore::MediaElementSession::visibilityChanged): 45 (WebCore::MediaElementSession::isVisibleInViewportChanged): 46 (WebCore::MediaElementSession::inActiveDocumentChanged): 47 (WebCore::MediaElementSession::scheduleClientDataBufferingCheck): 48 (WebCore::MediaElementSession::clientDataBufferingTimerFired): 49 (WebCore::MediaElementSession::updateClientDataBuffering): 50 (WebCore::MediaElementSession::dataBufferingPermitted const): 51 (WebCore::MediaElementSession::wantsToObserveViewportVisibilityForAutoplay const): 52 * html/MediaElementSession.h: 53 * platform/audio/PlatformMediaSession.cpp: 54 (WebCore::PlatformMediaSession::PlatformMediaSession): 55 (WebCore::PlatformMediaSession::clientWillBeginAutoplaying): 56 (WebCore::PlatformMediaSession::clientWillBeginPlayback): 57 (WebCore::PlatformMediaSession::clientWillPausePlayback): 58 (): Deleted. 59 (WebCore::PlatformMediaSession::visibilityChanged): Deleted. 60 (WebCore::PlatformMediaSession::scheduleClientDataBufferingCheck): Deleted. 61 (WebCore::PlatformMediaSession::clientDataBufferingTimerFired): Deleted. 62 (WebCore::PlatformMediaSession::updateClientDataBuffering): Deleted. 63 (WebCore::PlatformMediaSession::isHidden const): Deleted. 64 * platform/audio/PlatformMediaSession.h: 65 (WebCore::PlatformMediaSessionClient::setShouldBufferData): Deleted. 66 (WebCore::PlatformMediaSessionClient::elementIsHidden const): Deleted. 67 * platform/audio/PlatformMediaSessionManager.cpp: 68 (WebCore::PlatformMediaSessionManager::sessionCanLoadMedia const): Deleted. 69 * platform/audio/PlatformMediaSessionManager.h: 70 * platform/audio/ios/MediaSessionManagerIOS.h: 71 * platform/audio/ios/MediaSessionManagerIOS.mm: 72 (WebCore::MediaSessionManageriOS::sessionCanLoadMedia const): Deleted. 73 * rendering/RenderVideo.cpp: 74 (WebCore::RenderVideo::willBeDestroyed): 75 * testing/Internals.cpp: 76 (WebCore::Internals::elementShouldBufferData): 77 * testing/Internals.h: 78 * testing/Internals.idl: 79 1 80 2018-05-15 Charles Vazac <cvazac@gmail.com> 2 81 -
TabularUnified trunk/Source/WebCore/html/HTMLMediaElement.cpp ¶
r231392 r231817 478 478 , m_havePreparedToPlay(false) 479 479 , m_parsingInProgress(createdByParser) 480 , m_shouldBufferData(true) 480 481 , m_elementIsHidden(document.hidden()) 481 482 , m_creatingControls(false) … … 927 928 HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); 928 929 if (insertionType.connectedToDocument) 929 m_inActiveDocument = true;930 setInActiveDocument(true); 930 931 931 932 return InsertedIntoAncestorResult::NeedsPostInsertionCallback; … … 979 980 INFO_LOG(LOGIDENTIFIER); 980 981 981 m_inActiveDocument = false;982 setInActiveDocument(false); 982 983 if (removalType.disconnectedFromDocument) { 983 984 // Pause asynchronously to let the operation that removed us finish, in case we get inserted back into a document. … … 3468 3469 return; 3469 3470 } 3470 3471 3471 3472 // 4.8.10.9. Playing the media resource 3472 3473 if (!m_player || m_networkState == NETWORK_EMPTY) … … 5521 5522 5522 5523 updatePlaybackControlsManager(); 5523 m_inActiveDocument = false;5524 setInActiveDocument(false); 5524 5525 5525 5526 // Stop the playback without generating events … … 5601 5602 INFO_LOG(LOGIDENTIFIER); 5602 5603 5603 m_inActiveDocument = true;5604 setInActiveDocument(true); 5604 5605 5605 5606 m_asyncEventQueue.resume(); … … 5639 5640 void HTMLMediaElement::visibilityStateChanged() 5640 5641 { 5641 m_elementIsHidden = document().hidden() && m_videoFullscreenMode != VideoFullscreenModePictureInPicture; 5642 bool elementIsHidden = document().hidden() && m_videoFullscreenMode != VideoFullscreenModePictureInPicture; 5643 if (elementIsHidden == m_elementIsHidden) 5644 return; 5645 5646 m_elementIsHidden = elementIsHidden; 5642 5647 INFO_LOG(LOGIDENTIFIER, "visible = ", !m_elementIsHidden); 5648 5643 5649 updateSleepDisabling(); 5644 5650 m_mediaSession->visibilityChanged(); … … 6500 6506 #endif 6501 6507 m_player = MediaPlayer::create(*this); 6508 m_player->setShouldBufferData(m_shouldBufferData); 6502 6509 scheduleUpdatePlaybackControlsManager(); 6503 6510 … … 7661 7668 void HTMLMediaElement::setShouldBufferData(bool shouldBuffer) 7662 7669 { 7670 if (shouldBuffer == m_shouldBufferData) 7671 return; 7672 7673 m_shouldBufferData = shouldBuffer; 7663 7674 if (m_player) 7664 7675 m_player->setShouldBufferData(shouldBuffer); … … 7668 7679 { 7669 7680 #if PLATFORM(IOS) 7670 if (!MemoryPressureHandler::singleton().isUnderMemoryPressure() && PlatformMediaSessionManager::sharedManager().sessionCanLoadMedia(*m_mediaSession))7681 if (!MemoryPressureHandler::singleton().isUnderMemoryPressure() && m_mediaSession->dataBufferingPermitted()) 7671 7682 return; 7672 7683 … … 7776 7787 { 7777 7788 m_visibilityChangeTaskQueue.enqueueTask([this] { 7789 m_mediaSession->isVisibleInViewportChanged(); 7778 7790 updateShouldAutoplay(); 7779 7791 scheduleUpdatePlaybackControlsManager(); … … 7875 7887 m_videoFullscreenMode = mode; 7876 7888 visibilityStateChanged(); 7877 m_mediaSession->scheduleClientDataBufferingCheck();7878 7889 scheduleUpdatePlaybackControlsManager(); 7879 7890 } … … 7908 7919 } 7909 7920 7910 } 7911 7912 #endif 7921 void HTMLMediaElement::setInActiveDocument(bool inActiveDocument) 7922 { 7923 if (inActiveDocument == m_inActiveDocument) 7924 return; 7925 7926 m_inActiveDocument = inActiveDocument; 7927 m_mediaSession->inActiveDocumentChanged(); 7928 } 7929 7930 } 7931 7932 #endif -
TabularUnified trunk/Source/WebCore/html/HTMLMediaElement.h ¶
r231604 r231817 266 266 WEBCORE_EXPORT void play() override; 267 267 WEBCORE_EXPORT void pause() override; 268 void setShouldBufferData(bool) override; 268 void setShouldBufferData(bool); 269 WEBCORE_EXPORT bool shouldBufferData() const { return m_shouldBufferData; } 269 270 WEBCORE_EXPORT void fastSeek(double); 270 271 double minFastReverseRate() const; … … 278 279 WEBCORE_EXPORT void setWebkitClosedCaptionsVisible(bool); 279 280 280 bool elementIsHidden() const override{ return m_elementIsHidden; }281 bool elementIsHidden() const { return m_elementIsHidden; } 281 282 282 283 #if ENABLE(MEDIA_STATISTICS) … … 913 914 void applicationDidBecomeActive() final; 914 915 916 void setInActiveDocument(bool); 917 915 918 #if !RELEASE_LOG_DISABLED 916 919 const char* logClassName() const final { return "HTMLMediaElement"; } … … 1065 1068 bool m_havePreparedToPlay : 1; 1066 1069 bool m_parsingInProgress : 1; 1070 bool m_shouldBufferData : 1; 1067 1071 bool m_elementIsHidden : 1; 1072 bool m_elementWasRemovedFromDOM : 1; 1068 1073 bool m_creatingControls : 1; 1069 1074 bool m_receivedLayoutSizeChanged : 1; -
TabularUnified trunk/Source/WebCore/html/MediaElementSession.cpp ¶
r231604 r231817 57 57 namespace WebCore { 58 58 59 static const Seconds clientDataBufferingTimerThrottleDelay { 100_ms }; 59 60 static const Seconds elementMainContentCheckInterval { 250_ms }; 60 61 … … 110 111 #endif 111 112 , m_mainContentCheckTimer(*this, &MediaElementSession::mainContentCheckTimerFired) 113 , m_clientDataBufferingTimer(*this, &MediaElementSession::clientDataBufferingTimerFired) 112 114 #if !RELEASE_LOG_DISABLED 113 115 , m_logIdentifier(element.logIdentifier()) … … 132 134 UNUSED_PARAM(document); 133 135 #endif 136 } 137 138 void MediaElementSession::clientWillBeginAutoplaying() 139 { 140 PlatformMediaSession::clientWillBeginAutoplaying(); 141 m_elementIsHiddenBecauseItWasRemovedFromDOM = false; 142 updateClientDataBuffering(); 143 } 144 145 bool MediaElementSession::clientWillBeginPlayback() 146 { 147 if (!PlatformMediaSession::clientWillBeginPlayback()) 148 return false; 149 150 m_elementIsHiddenBecauseItWasRemovedFromDOM = false; 151 updateClientDataBuffering(); 152 return true; 153 } 154 155 bool MediaElementSession::clientWillPausePlayback() 156 { 157 if (!PlatformMediaSession::clientWillPausePlayback()) 158 return false; 159 160 updateClientDataBuffering(); 161 return true; 162 } 163 164 void MediaElementSession::visibilityChanged() 165 { 166 scheduleClientDataBufferingCheck(); 167 168 if (m_element.elementIsHidden() && !m_element.isFullscreen()) 169 m_elementIsHiddenUntilVisibleInViewport = true; 170 } 171 172 void MediaElementSession::isVisibleInViewportChanged() 173 { 174 scheduleClientDataBufferingCheck(); 175 176 if (m_element.isFullscreen() || m_element.isVisibleInViewport()) 177 m_elementIsHiddenUntilVisibleInViewport = false; 178 } 179 180 void MediaElementSession::inActiveDocumentChanged() 181 { 182 m_elementIsHiddenBecauseItWasRemovedFromDOM = !m_element.inActiveDocument(); 183 scheduleClientDataBufferingCheck(); 184 } 185 186 void MediaElementSession::scheduleClientDataBufferingCheck() 187 { 188 if (!m_clientDataBufferingTimer.isActive()) 189 m_clientDataBufferingTimer.startOneShot(clientDataBufferingTimerThrottleDelay); 190 } 191 192 void MediaElementSession::clientDataBufferingTimerFired() 193 { 194 INFO_LOG(LOGIDENTIFIER, "visible = ", m_element.elementIsHidden()); 195 196 updateClientDataBuffering(); 197 198 #if PLATFORM(IOS) 199 PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring(); 200 #endif 201 202 if (state() != Playing || !m_element.elementIsHidden()) 203 return; 204 205 PlatformMediaSessionManager::SessionRestrictions restrictions = PlatformMediaSessionManager::sharedManager().restrictions(mediaType()); 206 if ((restrictions & PlatformMediaSessionManager::BackgroundTabPlaybackRestricted) == PlatformMediaSessionManager::BackgroundTabPlaybackRestricted) 207 pauseSession(); 208 } 209 210 void MediaElementSession::updateClientDataBuffering() 211 { 212 if (m_clientDataBufferingTimer.isActive()) 213 m_clientDataBufferingTimer.stop(); 214 215 m_element.setShouldBufferData(dataBufferingPermitted()); 134 216 } 135 217 … … 276 358 } 277 359 360 bool MediaElementSession::dataBufferingPermitted() const 361 { 362 if (isSuspended()) 363 return false; 364 365 if (state() == PlatformMediaSession::Playing) 366 return true; 367 368 if (shouldOverrideBackgroundLoadingRestriction()) 369 return true; 370 371 if (m_elementIsHiddenUntilVisibleInViewport || m_elementIsHiddenBecauseItWasRemovedFromDOM || m_element.elementIsHidden()) 372 return false; 373 374 return true; 375 } 376 278 377 bool MediaElementSession::fullscreenPermitted() const 279 378 { … … 419 518 bool MediaElementSession::wantsToObserveViewportVisibilityForAutoplay() const 420 519 { 421 if (!m_element.isVideo()) 422 return false; 423 return hasBehaviorRestriction(InvisibleAutoplayNotPermitted) || hasBehaviorRestriction(OverrideUserGestureRequirementForMainContent); 520 return m_element.isVideo(); 424 521 } 425 522 … … 675 772 bool MediaElementSession::requiresPlaybackTargetRouteMonitoring() const 676 773 { 677 return m_hasPlaybackTargetAvailabilityListeners && ! client().elementIsHidden();774 return m_hasPlaybackTargetAvailabilityListeners && !m_element.elementIsHidden(); 678 775 } 679 776 #endif -
TabularUnified trunk/Source/WebCore/html/MediaElementSession.h ¶
r231604 r231817 62 62 void unregisterWithDocument(Document&); 63 63 64 void clientWillBeginAutoplaying() final; 65 bool clientWillBeginPlayback() final; 66 bool clientWillPausePlayback() final; 67 68 void visibilityChanged(); 69 void isVisibleInViewportChanged(); 70 void inActiveDocumentChanged(); 71 64 72 SuccessOr<MediaPlaybackDenialReason> playbackPermitted() const; 65 73 bool autoplayPermitted() const; 66 74 bool dataLoadingPermitted() const; 75 bool dataBufferingPermitted() const; 67 76 bool fullscreenPermitted() const; 68 77 bool pageAllowsDataLoading() const; … … 166 175 void mainContentCheckTimerFired(); 167 176 177 void scheduleClientDataBufferingCheck(); 178 void clientDataBufferingTimerFired(); 179 void updateClientDataBuffering(); 180 168 181 HTMLMediaElement& m_element; 169 182 BehaviorRestrictions m_restrictions; 183 184 bool m_elementIsHiddenUntilVisibleInViewport { false }; 185 bool m_elementIsHiddenBecauseItWasRemovedFromDOM { false }; 170 186 171 187 #if ENABLE(WIRELESS_PLAYBACK_TARGET) … … 183 199 mutable bool m_isMainContent { false }; 184 200 Timer m_mainContentCheckTimer; 201 Timer m_clientDataBufferingTimer; 185 202 186 203 #if !RELEASE_LOG_DISABLED -
TabularUnified trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp ¶
r231604 r231817 94 94 PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionClient& client) 95 95 : m_client(client) 96 , m_clientDataBufferingTimer(*this, &PlatformMediaSession::clientDataBufferingTimerFired)97 96 , m_state(Idle) 98 97 , m_stateToRestore(Idle) … … 177 176 178 177 setState(Autoplaying); 179 updateClientDataBuffering();180 178 } 181 179 … … 192 190 193 191 setState(Playing); 194 updateClientDataBuffering();195 192 return true; 196 193 } … … 210 207 setState(Paused); 211 208 PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this); 212 scheduleClientDataBufferingCheck();213 209 return true; 214 210 } … … 274 270 } 275 271 276 void PlatformMediaSession::visibilityChanged()277 {278 scheduleClientDataBufferingCheck();279 }280 281 void PlatformMediaSession::scheduleClientDataBufferingCheck()282 {283 if (!m_clientDataBufferingTimer.isActive())284 m_clientDataBufferingTimer.startOneShot(clientDataBufferingTimerThrottleDelay);285 }286 287 void PlatformMediaSession::clientDataBufferingTimerFired()288 {289 INFO_LOG(LOGIDENTIFIER, "visible = ", m_client.elementIsHidden());290 291 updateClientDataBuffering();292 293 #if PLATFORM(IOS)294 PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring();295 #endif296 297 if (m_state != Playing || !m_client.elementIsHidden())298 return;299 300 PlatformMediaSessionManager::SessionRestrictions restrictions = PlatformMediaSessionManager::sharedManager().restrictions(mediaType());301 if ((restrictions & PlatformMediaSessionManager::BackgroundTabPlaybackRestricted) == PlatformMediaSessionManager::BackgroundTabPlaybackRestricted)302 pauseSession();303 }304 305 void PlatformMediaSession::updateClientDataBuffering()306 {307 if (m_clientDataBufferingTimer.isActive())308 m_clientDataBufferingTimer.stop();309 310 m_client.setShouldBufferData(PlatformMediaSessionManager::sharedManager().sessionCanLoadMedia(*this));311 }312 313 272 String PlatformMediaSession::sourceApplicationIdentifier() const 314 273 { 315 274 return m_client.sourceApplicationIdentifier(); 316 }317 318 bool PlatformMediaSession::isHidden() const319 {320 return m_client.elementIsHidden();321 275 } 322 276 -
TabularUnified trunk/Source/WebCore/platform/audio/PlatformMediaSession.h ¶
r231604 r231817 106 106 void endInterruption(EndInterruptionFlags); 107 107 108 v oid clientWillBeginAutoplaying();109 bool clientWillBeginPlayback();110 bool clientWillPausePlayback();108 virtual void clientWillBeginAutoplaying(); 109 virtual bool clientWillBeginPlayback(); 110 virtual bool clientWillPausePlayback(); 111 111 112 112 void pauseSession(); 113 113 void stopSession(); 114 114 115 void visibilityChanged();116 117 115 #if ENABLE(VIDEO) 118 116 String title() const; … … 172 170 void canProduceAudioChanged(); 173 171 174 void scheduleClientDataBufferingCheck();175 172 virtual void resetPlaybackSessionState() { } 176 173 String sourceApplicationIdentifier() const; … … 189 186 190 187 private: 191 void clientDataBufferingTimerFired();192 void updateClientDataBuffering();193 194 188 PlatformMediaSessionClient& m_client; 195 Timer m_clientDataBufferingTimer;196 189 State m_state; 197 190 State m_stateToRestore; … … 233 226 virtual bool supportsSeeking() const = 0; 234 227 235 virtual void setShouldBufferData(bool) { }236 virtual bool elementIsHidden() const { return false; }237 228 virtual bool canProduceAudio() const { return false; } 238 229 virtual bool isSuspended() const { return false; }; -
TabularUnified trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp ¶
r228043 r231817 288 288 } 289 289 290 bool PlatformMediaSessionManager::sessionCanLoadMedia(const PlatformMediaSession& session) const291 {292 if (session.isSuspended())293 return false;294 return session.state() == PlatformMediaSession::Playing || !session.isHidden() || session.shouldOverrideBackgroundLoadingRestriction();295 }296 297 290 void PlatformMediaSessionManager::applicationWillBecomeInactive() const 298 291 { -
TabularUnified trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h ¶
r229893 r231817 95 95 virtual bool sessionWillBeginPlayback(PlatformMediaSession&); 96 96 virtual void sessionWillEndPlayback(PlatformMediaSession&); 97 virtual bool sessionCanLoadMedia(const PlatformMediaSession&) const;98 97 virtual void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) { }; 99 98 virtual void clientCharacteristicsChanged(PlatformMediaSession&) { } -
TabularUnified trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h ¶
r228531 r231817 66 66 void configureWireLessTargetMonitoring() override; 67 67 68 bool sessionCanLoadMedia(const PlatformMediaSession&) const override;69 70 68 bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; } 71 69 String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; } -
TabularUnified trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm ¶
r230490 r231817 302 302 } 303 303 304 bool MediaSessionManageriOS::sessionCanLoadMedia(const PlatformMediaSession& session) const305 {306 if (session.displayType() == PlatformMediaSession::Optimized)307 return true;308 309 return PlatformMediaSessionManager::sessionCanLoadMedia(session);310 }311 312 304 void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange() 313 305 { -
TabularUnified trunk/Source/WebCore/rendering/RenderVideo.cpp ¶
r228908 r231817 65 65 void RenderVideo::willBeDestroyed() 66 66 { 67 visibleInViewportStateChanged(); 67 68 if (auto player = videoElement().player()) 68 69 player->setVisible(false); -
TabularUnified trunk/Source/WebCore/testing/Internals.cpp ¶
r231798 r231817 3233 3233 } 3234 3234 3235 bool Internals::elementShouldBufferData(HTMLMediaElement& element) 3236 { 3237 return element.shouldBufferData(); 3238 } 3239 3235 3240 #endif 3236 3241 -
TabularUnified trunk/Source/WebCore/testing/Internals.h ¶
r231779 r231817 474 474 void beginSimulatedHDCPError(HTMLMediaElement&); 475 475 void endSimulatedHDCPError(HTMLMediaElement&); 476 477 bool elementShouldBufferData(HTMLMediaElement&); 476 478 #endif 477 479 -
TabularUnified trunk/Source/WebCore/testing/Internals.idl ¶
r231779 r231817 430 430 [Conditional=VIDEO] void endSimulatedHDCPError(HTMLMediaElement media); 431 431 432 [Conditional=VIDEO] boolean elementShouldBufferData(HTMLMediaElement media); 433 432 434 [Conditional=LEGACY_ENCRYPTED_MEDIA] void initializeMockCDM(); 433 435 [Conditional=ENCRYPTED_MEDIA] MockCDMFactory registerMockCDM();
Note:
See TracChangeset
for help on using the changeset viewer.