Changeset 226150 in webkit


Ignore:
Timestamp:
Dec 19, 2017 3:16:09 PM (6 years ago)
Author:
jer.noble@apple.com
Message:

Playing media elements which call "pause(); play()" will have the play promise rejected.
https://bugs.webkit.org/show_bug.cgi?id=180781
<rdar://problem/33191377>

Reviewed by Eric Carlson.

Source/WebCore:

Follow-up to address failing iOS API tests. Rather than skipping the call to
prepareForLoad() in the case where media elements are not allowed to load data,
unconditionally call prepareForLoad(), but conditionally call selectMediaResource() inside
that function only if the media elemnet is allowed to load. This ensures that the
MediaPlayer is created when play(), pause(), or load() are called during a user gesture
later, and selectMediaResource() (which depends on having a non-null m_player) is called.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute):
(WebCore::HTMLMediaElement::insertedIntoAncestor):
(WebCore::HTMLMediaElement::load):
(WebCore::HTMLMediaElement::prepareForLoad):
(WebCore::HTMLMediaElement::playInternal):

Source/WebKit:

shouldRequireUserGestureToLoadVideo() should default to false on Mac.

  • UIProcess/API/Cocoa/WKWebView.mm:

(shouldRequireUserGestureToLoadVideo):

Source/WebKitLegacy/mac:

shouldRequireUserGestureToLoadVideo() should default to false on Mac.

  • WebView/WebView.mm:

(shouldRequireUserGestureToLoadVideo):

LayoutTests:

  • media/video-load-require-user-gesture.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r226141 r226150  
     12017-12-19  Jer Noble  <jer.noble@apple.com>
     2
     3        Playing media elements which call "pause(); play()" will have the play promise rejected.
     4        https://bugs.webkit.org/show_bug.cgi?id=180781
     5        <rdar://problem/33191377>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * media/video-load-require-user-gesture.html:
     10
    1112017-12-19  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/LayoutTests/media/video-load-require-user-gesture.html

    r197953 r226150  
    77            var userGestureInitiated = 0;
    88
    9             if (window.internals)
     9            if (window.internals) {
    1010                window.internals.settings.setVideoPlaybackRequiresUserGesture(true);
     11                window.internals.settings.setRequiresUserGestureToLoadVideo(true);
     12            }
    1113
    1214            function finishTest(success)
  • trunk/Source/WebCore/ChangeLog

    r226142 r226150  
     12017-12-19  Jer Noble  <jer.noble@apple.com>
     2
     3        Playing media elements which call "pause(); play()" will have the play promise rejected.
     4        https://bugs.webkit.org/show_bug.cgi?id=180781
     5        <rdar://problem/33191377>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Follow-up to address failing iOS API tests. Rather than skipping the call to
     10        prepareForLoad() in the case where media elements are not allowed to load data,
     11        unconditionally call prepareForLoad(), but conditionally call selectMediaResource() inside
     12        that function only if the media elemnet is allowed to load. This ensures that the
     13        MediaPlayer is created when play(), pause(), or load() are called during a user gesture
     14        later, and selectMediaResource() (which depends on having a non-null m_player) is called.
     15
     16        * html/HTMLMediaElement.cpp:
     17        (WebCore::HTMLMediaElement::parseAttribute):
     18        (WebCore::HTMLMediaElement::insertedIntoAncestor):
     19        (WebCore::HTMLMediaElement::load):
     20        (WebCore::HTMLMediaElement::prepareForLoad):
     21        (WebCore::HTMLMediaElement::playInternal):
     22
    1232017-12-19  Timothy Hatcher  <timothy@hatcher.name>
    224
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r226059 r226150  
    836836        // If a src attribute of a media element is set or changed, the user
    837837        // agent must invoke the media element's media element load algorithm.
    838 #if PLATFORM(IOS)
    839         // Note, unless the restriction on requiring user action has been removed,
    840         // do not begin downloading data on iOS.
    841         if (!value.isNull() && m_mediaSession->dataLoadingPermitted(*this))
    842 #else
    843838        if (!value.isNull())
    844 #endif
    845839            prepareForLoad();
    846840    } else if (name == controlsAttr)
     
    919913        m_inActiveDocument = true;
    920914
    921 #if PLATFORM(IOS)
    922         if (m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty() && m_mediaSession->dataLoadingPermitted(*this))
    923 #else
    924915        if (m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty())
    925 #endif
    926916            prepareForLoad();
    927917    }
     
    12331223    INFO_LOG(LOGIDENTIFIER);
    12341224
    1235     if (!m_mediaSession->dataLoadingPermitted(*this))
    1236         return;
    12371225    if (processingUserGestureForMedia())
    12381226        removeBehaviorsRestrictionsAfterFirstUserGesture();
     
    13431331
    13441332    // 9 - Invoke the media element's resource selection algorithm.
    1345     selectMediaResource();
     1333    // Note, unless the restriction on requiring user action has been removed,
     1334    // do not begin downloading data.
     1335    if (m_mediaSession->dataLoadingPermitted(*this))
     1336        selectMediaResource();
    13461337
    13471338    // 10 - Note: Playback of any previously playing media resource for this element stops.
     
    34523443    if (!m_mediaSession->clientWillBeginPlayback()) {
    34533444        ALWAYS_LOG(LOGIDENTIFIER, "  returning because of interruption");
    3454         return; // Treat as success because we will begin playback on cessation of the interruption.
     3445        return;
    34553446    }
    34563447
  • trunk/Source/WebCore/page/SettingsDefaultValues.h

    r223432 r226150  
    7171static const bool defaultMediaControlsScaleWithPageZoom = true;
    7272static const bool defaultQuickTimePluginReplacementEnabled = true;
     73static const bool defaultRequiresUserGestureToLoadVideo = true;
    7374#else
    7475static const bool defaultFixedBackgroundsPaintRelativeToDocument = false;
     
    8485static const bool defaultMediaControlsScaleWithPageZoom = true;
    8586static const bool defaultQuickTimePluginReplacementEnabled = false;
     87static const bool defaultRequiresUserGestureToLoadVideo = false;
    8688#endif
    8789
    88 static const bool defaultRequiresUserGestureToLoadVideo = true;
    8990static const bool defaultAllowsPictureInPictureMediaPlayback = true;
    9091
  • trunk/Source/WebKit/ChangeLog

    r226136 r226150  
     12017-12-19  Jer Noble  <jer.noble@apple.com>
     2
     3        Playing media elements which call "pause(); play()" will have the play promise rejected.
     4        https://bugs.webkit.org/show_bug.cgi?id=180781
     5        <rdar://problem/33191377>
     6
     7        Reviewed by Eric Carlson.
     8
     9        shouldRequireUserGestureToLoadVideo() should default to false on Mac.
     10
     11        * UIProcess/API/Cocoa/WKWebView.mm:
     12        (shouldRequireUserGestureToLoadVideo):
     13
    1142017-12-19  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r226008 r226150  
    431431    return shouldRequireUserGestureToLoadVideo;
    432432#else
    433     return true;
     433    return false;
    434434#endif
    435435}
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r226148 r226150  
     12017-12-19  Jer Noble  <jer.noble@apple.com>
     2
     3        Playing media elements which call "pause(); play()" will have the play promise rejected.
     4        https://bugs.webkit.org/show_bug.cgi?id=180781
     5        <rdar://problem/33191377>
     6
     7        Reviewed by Eric Carlson.
     8
     9        shouldRequireUserGestureToLoadVideo() should default to false on Mac.
     10
     11        * WebView/WebView.mm:
     12        (shouldRequireUserGestureToLoadVideo):
     13
    1142017-12-19  Wenson Hsieh  <wenson_hsieh@apple.com>
    215
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r225669 r226150  
    13111311    return shouldRequireUserGestureToLoadVideo;
    13121312#else
    1313     return true;
     1313    return false;
    13141314#endif
    13151315}
Note: See TracChangeset for help on using the changeset viewer.