Title: [271470] trunk/Source/WebCore
Revision
271470
Author
[email protected]
Date
2021-01-13 15:32:21 -0800 (Wed, 13 Jan 2021)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271469 => 271470)


--- trunk/Source/WebCore/ChangeLog	2021-01-13 23:27:18 UTC (rev 271469)
+++ trunk/Source/WebCore/ChangeLog	2021-01-13 23:32:21 UTC (rev 271470)
@@ -1,3 +1,22 @@
+2021-01-13  Jer Noble  <[email protected]>
+
+        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:
+
 2021-01-13  Wenson Hsieh  <[email protected]>
 
         [macOS] "Correct Spelling Automatically" menu items are inconsistent when autocorrect="off"

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (271469 => 271470)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2021-01-13 23:27:18 UTC (rev 271469)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2021-01-13 23:32:21 UTC (rev 271470)
@@ -315,6 +315,14 @@
 
     // FIXME: Why are we checking top-level document only for PerDocumentAutoplayBehavior?
     const auto& topDocument = document.topDocument();
+    if (topDocument.quirks().requiresUserGestureToPauseInPictureInPicture()
+        && m_element.fullscreenMode() & HTMLMediaElementEnums::VideoFullscreenModePictureInPicture
+        && !m_element.paused()
+        && !document.processingUserGestureForMedia()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a quirk requires a user gesture to pause while in Picture-in-Picture");
+        return MediaPlaybackDenialReason::UserGestureRequired;
+    }
+
     if (topDocument.mediaState() & MediaProducer::HasUserInteractedWithMediaElement && topDocument.quirks().needsPerDocumentAutoplayBehavior())
         return { };
 

Modified: trunk/Source/WebCore/page/Quirks.cpp (271469 => 271470)


--- trunk/Source/WebCore/page/Quirks.cpp	2021-01-13 23:27:18 UTC (rev 271469)
+++ trunk/Source/WebCore/page/Quirks.cpp	2021-01-13 23:32:21 UTC (rev 271470)
@@ -45,6 +45,7 @@
 #include "NamedNodeMap.h"
 #include "NetworkStorageSession.h"
 #include "PlatformMouseEvent.h"
+#include "RegistrableDomain.h"
 #include "ResourceLoadObserver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGPathElement.h"
@@ -1258,4 +1259,18 @@
     return *m_needsBlackFullscreenBackgroundQuirk;
 }
 
+bool Quirks::requiresUserGestureToPauseInPictureInPicture() const
+{
+    // Facebook will naively pause a <video> element that has scrolled out of the viewport, regardless of whether that element is currently in PiP mode.
+    if (!needsQuirks())
+        return false;
+
+    if (!m_requiresUserGestureToPauseInPictureInPicture) {
+        auto domain = RegistrableDomain(m_document->topDocument().url());
+        m_requiresUserGestureToPauseInPictureInPicture = domain.string() == "facebook.com"_s;
+    }
+
+    return *m_requiresUserGestureToPauseInPictureInPicture;
 }
+
+}

Modified: trunk/Source/WebCore/page/Quirks.h (271469 => 271470)


--- trunk/Source/WebCore/page/Quirks.h	2021-01-13 23:27:18 UTC (rev 271469)
+++ trunk/Source/WebCore/page/Quirks.h	2021-01-13 23:32:21 UTC (rev 271470)
@@ -127,6 +127,8 @@
 
     bool needsBlackFullscreenBackgroundQuirk() const;
 
+    bool requiresUserGestureToPauseInPictureInPicture() const;
+
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     static bool isMicrosoftTeamsRedirectURL(const URL&);
     static bool hasStorageAccessForAllLoginDomains(const HashSet<RegistrableDomain>&, const RegistrableDomain&);
@@ -167,6 +169,7 @@
     mutable Optional<bool> m_needsVP9FullRangeFlagQuirk;
     mutable Optional<bool> m_needsHDRPixelDepthQuirk;
     mutable Optional<bool> m_needsBlackFullscreenBackgroundQuirk;
+    mutable Optional<bool> m_requiresUserGestureToPauseInPictureInPicture;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to