Bug 216287 - Returning to element fullscreen from PiP is not stable under stress tests
Summary: Returning to element fullscreen from PiP is not stable under stress tests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Peng Liu
URL:
Keywords: InRadar
Depends on:
Blocks: 216051 216426
  Show dependency treegraph
 
Reported: 2020-09-08 15:31 PDT by Peng Liu
Modified: 2020-09-15 11:16 PDT (History)
7 users (show)

See Also:


Attachments
Patch (25.70 KB, patch)
2020-09-08 16:39 PDT, Peng Liu
no flags Details | Formatted Diff | Diff
Fix an api test failure on Mac (34.46 KB, patch)
2020-09-10 21:34 PDT, Peng Liu
no flags Details | Formatted Diff | Diff
Update the patch based on Jer's comments (35.08 KB, patch)
2020-09-14 13:27 PDT, Peng Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peng Liu 2020-09-08 15:31:35 PDT
Return to element fullscreen from PiP is not stable under stress tests
Comment 1 Radar WebKit Bug Importer 2020-09-08 15:32:24 PDT
<rdar://problem/68533983>
Comment 2 Peng Liu 2020-09-08 16:39:47 PDT
Created attachment 408284 [details]
Patch
Comment 3 Peng Liu 2020-09-10 21:34:41 PDT
Created attachment 408510 [details]
Fix an api test failure on Mac
Comment 4 Jer Noble 2020-09-14 10:47:38 PDT
Comment on attachment 408510 [details]
Fix an api test failure on Mac

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

> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:700
> +                videoFullscreenManager->setClient(&_videoFullscreenManagerProxyClient);

Here.

> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:851
> +                videoFullscreenManager->setClient(nullptr);

And here.

> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:932
> +    if (![self isFullScreen]) {
> +        if (auto* videoFullscreenManager = self._videoFullscreenManager)
> +            videoFullscreenManager->setClient(nullptr);
> +    }

And here.

> Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm:655
> +    if (auto* videoFullscreenManager = self._videoFullscreenManager)
> +        videoFullscreenManager->setClient(nullptr);

And here.

> Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm:691
> +    if (auto* videoFullscreenManager = self._videoFullscreenManager)
> +        videoFullscreenManager->setClient(&_videoFullscreenManagerProxyClient);

And here.

What will happen if some other piece of code reset videoFullScreenManager's client, perhaps by requesting fullscreen before this animation is complete?  VideoFullscreenManager is a singleton, so would that cause us to get into a bad state in the manager's state machine?
Comment 5 Peng Liu 2020-09-14 11:24:39 PDT
Comment on attachment 408510 [details]
Fix an api test failure on Mac

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

>> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:851
>> +                videoFullscreenManager->setClient(nullptr);
> 
> And here.

I guess it is better to move this section out of the _repaintCallback?

>> Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm:691
>> +        videoFullscreenManager->setClient(&_videoFullscreenManagerProxyClient);
> 
> And here.
> 
> What will happen if some other piece of code reset videoFullScreenManager's client, perhaps by requesting fullscreen before this animation is complete?  VideoFullscreenManager is a singleton, so would that cause us to get into a bad state in the manager's state machine?

FullscreenManager has the logic to ignore a new fullscreen mode changing request if the current request is not completed yet. Also, WKFullScreenWindowControllerVideoFullscreenManagerProxyClient is the only one client of VideoFullscreenManagerProxy, and only WKFullScreenWindowController calls VideoFullscreenManagerProxy::setClient(). So I believe the code is safe.
Comment 6 Jer Noble 2020-09-14 12:02:29 PDT
(In reply to Peng Liu from comment #5)
> Comment on attachment 408510 [details]
> Fix an api test failure on Mac
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=408510&action=review
> 
> >> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:851
> >> +                videoFullscreenManager->setClient(nullptr);
> > 
> > And here.
> 
> I guess it is better to move this section out of the _repaintCallback?
> 
> >> Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm:691
> >> +        videoFullscreenManager->setClient(&_videoFullscreenManagerProxyClient);
> > 
> > And here.
> > 
> > What will happen if some other piece of code reset videoFullScreenManager's client, perhaps by requesting fullscreen before this animation is complete?  VideoFullscreenManager is a singleton, so would that cause us to get into a bad state in the manager's state machine?
> 
> FullscreenManager has the logic to ignore a new fullscreen mode changing
> request if the current request is not completed yet. Also,
> WKFullScreenWindowControllerVideoFullscreenManagerProxyClient is the only
> one client of VideoFullscreenManagerProxy, and only
> WKFullScreenWindowController calls VideoFullscreenManagerProxy::setClient().
> So I believe the code is safe.

Might be worthwhile to put some ASSERT() statements around the setClient() calls, to catch this case should things ever go wrong.  I.e., assert that client is NULL when set, and that it's `this` when cleared.
Comment 7 Peng Liu 2020-09-14 13:27:40 PDT
Created attachment 408739 [details]
Update the patch based on Jer's comments
Comment 8 Peng Liu 2020-09-14 13:28:57 PDT
Comment on attachment 408510 [details]
Fix an api test failure on Mac

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

>>>> Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:851
>>>> +                videoFullscreenManager->setClient(nullptr);
>>> 
>>> And here.
>> 
>> I guess it is better to move this section out of the _repaintCallback?
> 
> Might be worthwhile to put some ASSERT() statements around the setClient() calls, to catch this case should things ever go wrong.  I.e., assert that client is NULL when set, and that it's `this` when cleared.

Good point!
Comment 9 EWS 2020-09-14 15:39:55 PDT
Committed r267053: <https://trac.webkit.org/changeset/267053>

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