Bug 220581 - Facebook pauses video in PiP during scroll
Summary: Facebook pauses video in PiP during scroll
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-12 23:51 PST by Jer Noble
Modified: 2021-01-13 15:32 PST (History)
13 users (show)

See Also:


Attachments
Patch (4.29 KB, patch)
2021-01-12 23:55 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (4.47 KB, patch)
2021-01-13 12:56 PST, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2021-01-12 23:51:46 PST
Facebook pauses video in PiP during scroll
Comment 1 Jer Noble 2021-01-12 23:52:04 PST
<rdar://67273166>
Comment 2 Jer Noble 2021-01-12 23:55:07 PST
Created attachment 417514 [details]
Patch
Comment 3 Sam Weinig 2021-01-13 08:30:54 PST
Comment on attachment 417514 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417514&action=review

> Source/WebCore/ChangeLog:12
> +        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.

Hey Jer, I've definitely seen this issue on there sites as well (I know this because I don't use Facebook and have seen this, but can't recall where). What are your thoughts on just making this the rule for all sites: pausing PIP requires a user gesture?
Comment 4 Jer Noble 2021-01-13 10:01:38 PST
(In reply to Sam Weinig from comment #3)
> Comment on attachment 417514 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=417514&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        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.
> 
> Hey Jer, I've definitely seen this issue on there sites as well (I know this
> because I don't use Facebook and have seen this, but can't recall where).
> What are your thoughts on just making this the rule for all sites: pausing
> PIP requires a user gesture?

I'm sympathetic. Since we added an "enter pip" button in the default controls (and similar affordance elsewhere), it's easy for sites to completely miss that the user has put the video into PiP. 

However, I can also definitely see pitfalls. We've evangelized our autoplay rules which state that once you've "unlocked" a media element with a user gesture, you don't need additional ones to change the play state. Sites with complicated React.js style re-dispatching event handlers might have unexpected behavior.

It might still be worth it though.
Comment 5 Kate Cheney 2021-01-13 10:52:41 PST
Comment on attachment 417514 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417514&action=review

> Source/WebCore/page/Quirks.cpp:1269
> +        m_requiresUserGestureToPauseInPictureInPicture = equalLettersIgnoringASCIICase(host, "facebook.com") || host.endsWithIgnoringASCIICase(".facebook.com");

If you wanted, I think you could do something like:

auto domain = RegistrableDomain(m_document->topDocument().url());
m_requiresUserGestureToPauseInPictureInPicture = domain.string() == "facebook.com"_s;

It would make it so you don't need the extra check for the subdomain case .facebook.com (RegistrableDomain will parse the domain for you).
Comment 6 Jer Noble 2021-01-13 11:28:42 PST
(In reply to katherine_cheney from comment #5)
> Comment on attachment 417514 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=417514&action=review
> 
> > Source/WebCore/page/Quirks.cpp:1269
> > +        m_requiresUserGestureToPauseInPictureInPicture = equalLettersIgnoringASCIICase(host, "facebook.com") || host.endsWithIgnoringASCIICase(".facebook.com");
> 
> If you wanted, I think you could do something like:
> 
> auto domain = RegistrableDomain(m_document->topDocument().url());
> m_requiresUserGestureToPauseInPictureInPicture = domain.string() ==
> "facebook.com"_s;
> 
> It would make it so you don't need the extra check for the subdomain case
> .facebook.com (RegistrableDomain will parse the domain for you).

Oooh, super glad someone finally made this utility class. Will adopt.
Comment 7 Jer Noble 2021-01-13 12:56:35 PST
Created attachment 417553 [details]
Patch
Comment 8 EWS 2021-01-13 15:32:27 PST
Committed r271470: <https://trac.webkit.org/changeset/271470>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417553 [details].