Changeset 250935 in webkit


Ignore:
Timestamp:
Oct 9, 2019 3:03:29 PM (5 years ago)
Author:
Chris Dumez
Message:

Youtube.com is unable to enter the back/forward cache on macOS
https://bugs.webkit.org/show_bug.cgi?id=202754
<rdar://problem/56117666>

Reviewed by Eric Carlson.

Source/WebCore:

As of r250542, the MainThreadGenericEventQueue used by both MediaSource and
SourceBuffer to fire event is PageCache-aware. As a result, both these
ActiveDOMObjects can now safety suspend without risking running script while
in the page cache. I did have to update some logic in MediaSource::removeSourceBuffer()
to make sure we do not unnecessarily construct new ActiveDOMObjects while
suspending, as this is not allowed.

Test: media/media-source/media-source-page-cache.html

  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::removeSourceBuffer):
(WebCore::MediaSource::canSuspendForDocumentSuspension const):

  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::canSuspendForDocumentSuspension const):

  • Modules/mediasource/SourceBuffer.h:

LayoutTests:

Add layout test coverage.

  • media/media-source/media-source-page-cache-expected.txt: Added.
  • media/media-source/media-source-page-cache.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250931 r250935  
     12019-10-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Youtube.com is unable to enter the back/forward cache on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=202754
     5        <rdar://problem/56117666>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Add layout test coverage.
     10
     11        * media/media-source/media-source-page-cache-expected.txt: Added.
     12        * media/media-source/media-source-page-cache.html: Added.
     13
    1142019-10-09  Truitt Savell  <tsavell@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r250930 r250935  
     12019-10-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Youtube.com is unable to enter the back/forward cache on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=202754
     5        <rdar://problem/56117666>
     6
     7        Reviewed by Eric Carlson.
     8
     9        As of r250542, the MainThreadGenericEventQueue used by both MediaSource and
     10        SourceBuffer to fire event is PageCache-aware. As a result, both these
     11        ActiveDOMObjects can now safety suspend without risking running script while
     12        in the page cache. I did have to update some logic in MediaSource::removeSourceBuffer()
     13        to make sure we do not unnecessarily construct new ActiveDOMObjects while
     14        suspending, as this is not allowed.
     15
     16        Test: media/media-source/media-source-page-cache.html
     17
     18        * Modules/mediasource/MediaSource.cpp:
     19        (WebCore::MediaSource::removeSourceBuffer):
     20        (WebCore::MediaSource::canSuspendForDocumentSuspension const):
     21        * Modules/mediasource/SourceBuffer.cpp:
     22        (WebCore::SourceBuffer::canSuspendForDocumentSuspension const):
     23        * Modules/mediasource/SourceBuffer.h:
     24
    1252019-10-09  Daniel Bates  <dabates@apple.com>
    226
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp

    r250542 r250935  
    737737    if (!scriptExecutionContext()->activeDOMObjectsAreStopped()) {
    738738        // 4. Let SourceBuffer audioTracks list equal the AudioTrackList object returned by sourceBuffer.audioTracks.
    739         auto& audioTracks = buffer.audioTracks();
     739        auto* audioTracks = buffer.audioTracksIfExists();
    740740
    741741        // 5. If the SourceBuffer audioTracks list is not empty, then run the following steps:
    742         if (audioTracks.length()) {
     742        if (audioTracks && audioTracks->length()) {
    743743            // 5.1 Let HTMLMediaElement audioTracks list equal the AudioTrackList object returned by the audioTracks
    744744            // attribute on the HTMLMediaElement.
     
    747747
    748748            // 5.3 For each AudioTrack object in the SourceBuffer audioTracks list, run the following steps:
    749             while (audioTracks.length()) {
    750                 auto& track = *audioTracks.lastItem();
     749            while (audioTracks->length()) {
     750                auto& track = *audioTracks->lastItem();
    751751
    752752                // 5.3.1 Set the sourceBuffer attribute on the AudioTrack object to null.
     
    767767                // 5.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
    768768                // cancelable, and that uses the TrackEvent interface, at the SourceBuffer audioTracks list.
    769                 audioTracks.remove(track);
     769                audioTracks->remove(track);
    770770            }
    771771
     
    777777
    778778        // 6. Let SourceBuffer videoTracks list equal the VideoTrackList object returned by sourceBuffer.videoTracks.
    779         auto& videoTracks = buffer.videoTracks();
     779        auto* videoTracks = buffer.videoTracksIfExists();
    780780
    781781        // 7. If the SourceBuffer videoTracks list is not empty, then run the following steps:
    782         if (videoTracks.length()) {
     782        if (videoTracks && videoTracks->length()) {
    783783            // 7.1 Let HTMLMediaElement videoTracks list equal the VideoTrackList object returned by the videoTracks
    784784            // attribute on the HTMLMediaElement.
     
    787787
    788788            // 7.3 For each VideoTrack object in the SourceBuffer videoTracks list, run the following steps:
    789             while (videoTracks.length()) {
    790                 auto& track = *videoTracks.lastItem();
     789            while (videoTracks->length()) {
     790                auto& track = *videoTracks->lastItem();
    791791
    792792                // 7.3.1 Set the sourceBuffer attribute on the VideoTrack object to null.
     
    807807                // 7.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
    808808                // cancelable, and that uses the TrackEvent interface, at the SourceBuffer videoTracks list.
    809                 videoTracks.remove(track);
     809                videoTracks->remove(track);
    810810            }
    811811
     
    817817
    818818        // 8. Let SourceBuffer textTracks list equal the TextTrackList object returned by sourceBuffer.textTracks.
    819         auto& textTracks = buffer.textTracks();
     819        auto* textTracks = buffer.textTracksIfExists();
    820820
    821821        // 9. If the SourceBuffer textTracks list is not empty, then run the following steps:
    822         if (textTracks.length()) {
     822        if (textTracks && textTracks->length()) {
    823823            // 9.1 Let HTMLMediaElement textTracks list equal the TextTrackList object returned by the textTracks
    824824            // attribute on the HTMLMediaElement.
     
    827827
    828828            // 9.3 For each TextTrack object in the SourceBuffer textTracks list, run the following steps:
    829             while (textTracks.length()) {
    830                 auto& track = *textTracks.lastItem();
     829            while (textTracks->length()) {
     830                auto& track = *textTracks->lastItem();
    831831
    832832                // 9.3.1 Set the sourceBuffer attribute on the TextTrack object to null.
     
    847847                // 9.3.6 Queue a task to fire a trusted event named removetrack, that does not bubble and is not
    848848                // cancelable, and that uses the TrackEvent interface, at the SourceBuffer textTracks list.
    849                 textTracks.remove(track);
     849                textTracks->remove(track);
    850850            }
    851851
     
    990990bool MediaSource::canSuspendForDocumentSuspension() const
    991991{
    992     // FIXME: Do better.
    993     return isClosed();
     992    return true;
    994993}
    995994
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r250576 r250935  
    541541bool SourceBuffer::canSuspendForDocumentSuspension() const
    542542{
    543     return !hasPendingActivity();
     543    return true;
    544544}
    545545
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h

    r250542 r250935  
    8080#if ENABLE(VIDEO_TRACK)
    8181    VideoTrackList& videoTracks();
     82    VideoTrackList* videoTracksIfExists() const { return m_videoTracks.get(); }
    8283    AudioTrackList& audioTracks();
     84    AudioTrackList* audioTracksIfExists() const { return m_audioTracks.get(); }
    8385    TextTrackList& textTracks();
     86    TextTrackList* textTracksIfExists() const { return m_textTracks.get(); }
    8487#endif
    8588
Note: See TracChangeset for help on using the changeset viewer.