Changeset 271470 in webkit


Ignore:
Timestamp:
Jan 13, 2021 3:32:21 PM (18 months ago)
Author:
jer.noble@apple.com
Message:

Facebook pauses video in PiP during scroll
https://bugs.webkit.org/show_bug.cgi?id=220581
<rdar://67273166>

Reviewed by Eric Carlson.

Add a Quirk which blocks Facebook from pausing videos in Picture-in-Picture mode without that
pause() occurring during a User Gesture. This blocks Facebook from pausing a PiP'd video when
the <video> element hosting that video scrolls out of the viewport, without blocking Facebook's
own custom pause control from working correctly.

  • html/MediaElementSession.cpp:

(WebCore::MediaElementSession::playbackPermitted const):

  • page/Quirks.cpp:

(WebCore::Quirks::requiresUserGestureToPauseInPictureInPicture const):

  • page/Quirks.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271459 r271470  
     12021-01-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Facebook pauses video in PiP during scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=220581
     5        <rdar://67273166>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Add a Quirk which blocks Facebook from pausing videos in Picture-in-Picture mode without that
     10        pause() occurring during a User Gesture. This blocks Facebook from pausing a PiP'd video when
     11        the <video> element hosting that video scrolls out of the viewport, without blocking Facebook's
     12        own custom pause control from working correctly.
     13
     14        * html/MediaElementSession.cpp:
     15        (WebCore::MediaElementSession::playbackPermitted const):
     16        * page/Quirks.cpp:
     17        (WebCore::Quirks::requiresUserGestureToPauseInPictureInPicture const):
     18        * page/Quirks.h:
     19
    1202021-01-13  Wenson Hsieh  <wenson_hsieh@apple.com>
    221
  • trunk/Source/WebCore/html/MediaElementSession.cpp

    r264355 r271470  
    316316    // FIXME: Why are we checking top-level document only for PerDocumentAutoplayBehavior?
    317317    const auto& topDocument = document.topDocument();
     318    if (topDocument.quirks().requiresUserGestureToPauseInPictureInPicture()
     319        && m_element.fullscreenMode() & HTMLMediaElementEnums::VideoFullscreenModePictureInPicture
     320        && !m_element.paused()
     321        && !document.processingUserGestureForMedia()) {
     322        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a quirk requires a user gesture to pause while in Picture-in-Picture");
     323        return MediaPlaybackDenialReason::UserGestureRequired;
     324    }
     325
    318326    if (topDocument.mediaState() & MediaProducer::HasUserInteractedWithMediaElement && topDocument.quirks().needsPerDocumentAutoplayBehavior())
    319327        return { };
  • trunk/Source/WebCore/page/Quirks.cpp

    r271074 r271470  
    4646#include "NetworkStorageSession.h"
    4747#include "PlatformMouseEvent.h"
     48#include "RegistrableDomain.h"
    4849#include "ResourceLoadObserver.h"
    4950#include "RuntimeEnabledFeatures.h"
     
    12591260}
    12601261
    1261 }
     1262bool Quirks::requiresUserGestureToPauseInPictureInPicture() const
     1263{
     1264    // Facebook will naively pause a <video> element that has scrolled out of the viewport, regardless of whether that element is currently in PiP mode.
     1265    if (!needsQuirks())
     1266        return false;
     1267
     1268    if (!m_requiresUserGestureToPauseInPictureInPicture) {
     1269        auto domain = RegistrableDomain(m_document->topDocument().url());
     1270        m_requiresUserGestureToPauseInPictureInPicture = domain.string() == "facebook.com"_s;
     1271    }
     1272
     1273    return *m_requiresUserGestureToPauseInPictureInPicture;
     1274}
     1275
     1276}
  • trunk/Source/WebCore/page/Quirks.h

    r271415 r271470  
    128128    bool needsBlackFullscreenBackgroundQuirk() const;
    129129
     130    bool requiresUserGestureToPauseInPictureInPicture() const;
     131
    130132#if ENABLE(RESOURCE_LOAD_STATISTICS)
    131133    static bool isMicrosoftTeamsRedirectURL(const URL&);
     
    168170    mutable Optional<bool> m_needsHDRPixelDepthQuirk;
    169171    mutable Optional<bool> m_needsBlackFullscreenBackgroundQuirk;
     172    mutable Optional<bool> m_requiresUserGestureToPauseInPictureInPicture;
    170173};
    171174
Note: See TracChangeset for help on using the changeset viewer.