Title: [241077] branches/safari-607-branch/Source/WebCore
Revision
241077
Author
alanc...@apple.com
Date
2019-02-06 14:17:19 -0800 (Wed, 06 Feb 2019)

Log Message

Cherry-pick r240822. rdar://problem/47774539

    [Mac] Requesting PiP from two different WebViews gets PiP window "stuck"
    https://bugs.webkit.org/show_bug.cgi?id=194099
    <rdar://problem/47271323>

    Reviewed by Eric Carlson.

    When a different client requests the PiP window, the PiP framework will call -pipDidClose: without
    first calling -pipActionStop:. This leaves the internal fullscreen state in a confused state where
    the WebView will attempt to re-enter PiP once it gets focus, and can lead to a state where the two
    WebViews will constantly try to steal PiP from one another, ad infinitum.

    When receiving a notification that the PiP window closed when our internal state tells us that the
    close was not requested, notify the client that PiP mode was exited, allowing them to set their
    expected state to a correct and sane value.

    * platform/mac/VideoFullscreenInterfaceMac.mm:
    (-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240822 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (241076 => 241077)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-06 22:17:16 UTC (rev 241076)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-06 22:17:19 UTC (rev 241077)
@@ -1,5 +1,50 @@
 2019-02-05  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r240822. rdar://problem/47774539
+
+    [Mac] Requesting PiP from two different WebViews gets PiP window "stuck"
+    https://bugs.webkit.org/show_bug.cgi?id=194099
+    <rdar://problem/47271323>
+    
+    Reviewed by Eric Carlson.
+    
+    When a different client requests the PiP window, the PiP framework will call -pipDidClose: without
+    first calling -pipActionStop:. This leaves the internal fullscreen state in a confused state where
+    the WebView will attempt to re-enter PiP once it gets focus, and can lead to a state where the two
+    WebViews will constantly try to steal PiP from one another, ad infinitum.
+    
+    When receiving a notification that the PiP window closed when our internal state tells us that the
+    close was not requested, notify the client that PiP mode was exited, allowing them to set their
+    expected state to a correct and sane value.
+    
+    * platform/mac/VideoFullscreenInterfaceMac.mm:
+    (-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240822 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-31  Jer Noble  <jer.no...@apple.com>
+
+            [Mac] Requesting PiP from two different WebViews gets PiP window "stuck"
+            https://bugs.webkit.org/show_bug.cgi?id=194099
+            <rdar://problem/47271323>
+
+            Reviewed by Eric Carlson.
+
+            When a different client requests the PiP window, the PiP framework will call -pipDidClose: without
+            first calling -pipActionStop:. This leaves the internal fullscreen state in a confused state where
+            the WebView will attempt to re-enter PiP once it gets focus, and can lead to a state where the two
+            WebViews will constantly try to steal PiP from one another, ad infinitum.
+
+            When receiving a notification that the PiP window closed when our internal state tells us that the
+            close was not requested, notify the client that PiP mode was exited, allowing them to set their
+            expected state to a correct and sane value.
+
+            * platform/mac/VideoFullscreenInterfaceMac.mm:
+            (-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):
+
+2019-02-05  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r240773. rdar://problem/47774755
 
     ASSERTION FAILED: cache under WebCore::AXObjectCache::postTextStateChangePlatformNotification

Modified: branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm (241076 => 241077)


--- branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm	2019-02-06 22:17:16 UTC (rev 241076)
+++ branches/safari-607-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm	2019-02-06 22:17:19 UTC (rev 241077)
@@ -287,7 +287,16 @@
 {
     ASSERT_UNUSED(pip, pip == _pipViewController);
 
-    if (_videoFullscreenInterfaceMac && _videoFullscreenInterfaceMac->videoFullscreenModel() && _videoViewContainer && _returningWindow && !NSEqualRects(_returningRect, NSZeroRect)) {
+    if (!_videoFullscreenInterfaceMac)
+        return;
+
+    if (_pipState != PIPState::ExitingPIP) {
+        // We got told to close without going through -pipActionStop, nor by exlicitly being asked to in -exitPiP:.
+        // Call -pipActionStop: here in order to set the fullscreen state to an expected value.
+        [self pipActionStop:pip];
+    }
+
+    if (_videoFullscreenInterfaceMac->videoFullscreenModel() && _videoViewContainer && _returningWindow && !NSEqualRects(_returningRect, NSZeroRect)) {
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
             context.allowsImplicitAnimation = NO;
             [_videoViewContainer setFrame:_returningRect];
@@ -298,19 +307,17 @@
         } completionHandler:nil];
     }
 
-    if (_videoFullscreenInterfaceMac) {
-        if (!self.isExitingToStandardFullscreen) {
-            if (VideoFullscreenModel* videoFullscreenModel = _videoFullscreenInterfaceMac->videoFullscreenModel()) {
-                videoFullscreenModel->didExitPictureInPicture();
-                videoFullscreenModel->setVideoLayerGravity(MediaPlayerEnums::VideoGravityResizeAspect);
-            }
+    if (!self.isExitingToStandardFullscreen) {
+        if (VideoFullscreenModel* videoFullscreenModel = _videoFullscreenInterfaceMac->videoFullscreenModel()) {
+            videoFullscreenModel->didExitPictureInPicture();
+            videoFullscreenModel->setVideoLayerGravity(MediaPlayerEnums::VideoGravityResizeAspect);
         }
+    }
 
-        _videoFullscreenInterfaceMac->clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
+    if (VideoFullscreenChangeObserver* fullscreenChangeObserver = _videoFullscreenInterfaceMac->videoFullscreenChangeObserver())
+        fullscreenChangeObserver->didExitFullscreen();
 
-        if (VideoFullscreenChangeObserver* fullscreenChangeObserver = _videoFullscreenInterfaceMac->videoFullscreenChangeObserver())
-            fullscreenChangeObserver->didExitFullscreen();
-    }
+    _videoFullscreenInterfaceMac->clearMode(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
 }
 
 - (void)pipActionPlay:(PIPViewController *)pip
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to