RESOLVED FIXED 185487
Media continues loading after rendered invisible (removed from DOM; scrolled off screen)
https://bugs.webkit.org/show_bug.cgi?id=185487
Summary Media continues loading after rendered invisible (removed from DOM; scrolled ...
Jer Noble
Reported 2018-05-09 13:35:32 PDT
Media continues loading after rendered invisible (removed from DOM; scrolled off screen)
Attachments
Patch (36.29 KB, patch)
2018-05-09 13:42 PDT, Jer Noble
no flags
Archive of layout-test-results from ews100 for mac-sierra (2.48 MB, application/zip)
2018-05-09 14:32 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (5.96 MB, application/zip)
2018-05-09 14:53 PDT, EWS Watchlist
no flags
Patch for landing (44.29 KB, patch)
2018-05-09 15:53 PDT, Jer Noble
no flags
Patch for landing (42.73 KB, patch)
2018-05-14 10:21 PDT, Jer Noble
no flags
Patch for landing (44.06 KB, patch)
2018-05-14 11:07 PDT, Jer Noble
no flags
Archive of layout-test-results from ews117 for mac-sierra (3.55 MB, application/zip)
2018-05-14 13:08 PDT, EWS Watchlist
no flags
Patch for landing (44.08 KB, patch)
2018-05-14 16:40 PDT, Jer Noble
no flags
Jer Noble
Comment 1 2018-05-09 13:41:40 PDT
Jer Noble
Comment 2 2018-05-09 13:42:25 PDT
EWS Watchlist
Comment 3 2018-05-09 14:32:12 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 4 2018-05-09 14:32:13 PDT Comment hidden (obsolete)
Eric Carlson
Comment 5 2018-05-09 14:34:51 PDT
Comment on attachment 340016 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=340016&action=review r=me once the bots are also satisfied with it. > Source/WebCore/html/HTMLMediaElement.h:1072 > + bool m_elementWasRemovedFromDOM : 1; As you pointed out, this isn't used. > Source/WebCore/html/MediaElementSession.cpp:133 > + PlatformMediaSession::clientWillPausePlayback(); Don't you want to call PlatformMediaSession::clientWillBeginAutoplaying() instead? > Source/WebCore/html/MediaElementSession.cpp:134 > + m_elementWasRemovedFromDOM = false; Why does playback clear m_elementWasRemovedFromDOM? > Source/WebCore/html/MediaElementSession.cpp:143 > + m_elementWasRemovedFromDOM = false; Ditto. > Source/WebCore/html/MediaElementSession.cpp:162 > + if (m_element.elementIsHidden()) > + m_elementIsHiddenUntilVisibleInViewport = true; Should this also check m_element.isFullscreen as inisVisibleInViewportChanged? > LayoutTests/media/video-buffering-allowed.html:15 > + function waitFor(element, event) { > + return new Promise(resolve => { > + element.addEventListener(event, event => { > + consoleWrite(`EVENT(${event.type})`); > + resolve(event); > + }, { once: true }); > + }); > + } Nit: why not put this in video-test.js? > LayoutTests/media/video-buffering-allowed.html:30 > + run ('video.play()'); Nit: extra space after "run" > LayoutTests/media/video-test.js:106 > + return new Promise(async (resolve, reject) => { Nit: reject is not used.
EWS Watchlist
Comment 6 2018-05-09 14:53:11 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 7 2018-05-09 14:53:12 PDT Comment hidden (obsolete)
Jer Noble
Comment 8 2018-05-09 14:53:15 PDT
Comment on attachment 340016 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=340016&action=review >> Source/WebCore/html/MediaElementSession.cpp:133 >> + PlatformMediaSession::clientWillPausePlayback(); > > Don't you want to call PlatformMediaSession::clientWillBeginAutoplaying() instead? Oof, yes. >> Source/WebCore/html/MediaElementSession.cpp:134 >> + m_elementWasRemovedFromDOM = false; > > Why does playback clear m_elementWasRemovedFromDOM? We only want to block loading until the media element tries to play. If a video element was removed from the DOM, and then someone sets a src= and calls load(), we should unblock loading at this point. >> Source/WebCore/html/MediaElementSession.cpp:143 >> + m_elementWasRemovedFromDOM = false; > > Ditto. Ditto above. >> Source/WebCore/html/MediaElementSession.cpp:162 >> + m_elementIsHiddenUntilVisibleInViewport = true; > > Should this also check m_element.isFullscreen as inisVisibleInViewportChanged? So this is confusing. elementIsHidden() == document().hidden() && m_videoFullscreenMode != VideoFullscreenModePictureInPicture. So it's already checking whether it's PiP. I don't /think/ that the Document will be hidden() when the video element is in standard fullscreen mode, and it definitely won't when in element fullscreen mode. But just for sake of clarity, maybe we should explicitly check isFullscreen() here. >> LayoutTests/media/video-buffering-allowed.html:15 >> + } > > Nit: why not put this in video-test.js? Mostly just because of the risk of name collisions, and not wanting to make all the waitForEventAnd...() variants. :) >> LayoutTests/media/video-test.js:106 >> + return new Promise(async (resolve, reject) => { > > Nit: reject is not used. will remove.
Eric Carlson
Comment 9 2018-05-09 15:39:32 PDT
Comment on attachment 340016 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=340016&action=review >>> Source/WebCore/html/MediaElementSession.cpp:134 >>> + m_elementWasRemovedFromDOM = false; >> >> Why does playback clear m_elementWasRemovedFromDOM? > > We only want to block loading until the media element tries to play. If a video element was removed from the DOM, and then someone sets a src= and calls load(), we should unblock loading at this point. Sure, but m_elementWasRemovedFromDOM is probably not the right name for a variable that really means "allowed to load data". >>> Source/WebCore/html/MediaElementSession.cpp:143 >>> + m_elementWasRemovedFromDOM = false; >> >> Ditto. > > Ditto above. Ditto.
Jer Noble
Comment 10 2018-05-09 15:53:22 PDT
Created attachment 340045 [details] Patch for landing
Jer Noble
Comment 11 2018-05-14 10:21:27 PDT
Created attachment 340326 [details] Patch for landing
Jer Noble
Comment 12 2018-05-14 11:07:11 PDT
Created attachment 340332 [details] Patch for landing
EWS Watchlist
Comment 13 2018-05-14 13:08:35 PDT
Comment on attachment 340332 [details] Patch for landing Attachment 340332 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/7680059 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 14 2018-05-14 13:08:36 PDT
Created attachment 340347 [details] Archive of layout-test-results from ews117 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-sierra Platform: Mac OS X 10.12.6
Jer Noble
Comment 15 2018-05-14 16:40:04 PDT
Created attachment 340376 [details] Patch for landing
WebKit Commit Bot
Comment 16 2018-05-15 16:01:19 PDT
Comment on attachment 340376 [details] Patch for landing Clearing flags on attachment: 340376 Committed r231817: <https://trac.webkit.org/changeset/231817>
WebKit Commit Bot
Comment 17 2018-05-15 16:01:21 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.