Title: [185726] trunk/Source
Revision
185726
Author
[email protected]
Date
2015-06-18 16:38:55 -0700 (Thu, 18 Jun 2015)

Log Message

Fix crash when entering fullscreen during exit fullscreen animation.
https://bugs.webkit.org/show_bug.cgi?id=146117

Patch by Jeremy Jones <[email protected]> on 2015-06-18
Reviewed by Simon Fraser.

Source/WebCore:

Because enterFullscreen can be called during exitFullscreen animation, the exit fullscreen teardown
should not imply a fullscreen state change on video element.

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::exitFullscreen): May be called from mainThread
(-[WebVideoFullscreenController exitFullscreen]): May be called from mainThread
* platform/ios/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::setVideoElement):
Changing associated video element does not imply fullscreen mode change.

Source/WebKit2:

A partial teardown left the LayerHostingContext in a bad state when attempting to reuse the model and interface
objects. Instead, complete the teardown and don't reuse the objects.

* WebProcess/ios/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenManager::didEnterFullscreen): WebThreadRun is a no-op in WK2. Use dispatch_async.
(WebKit::WebVideoFullscreenManager::didCleanupFullscreen): Do complete teardown before entering fullscreen again.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185725 => 185726)


--- trunk/Source/WebCore/ChangeLog	2015-06-18 23:35:24 UTC (rev 185725)
+++ trunk/Source/WebCore/ChangeLog	2015-06-18 23:38:55 UTC (rev 185726)
@@ -1,3 +1,20 @@
+2015-06-18  Jeremy Jones  <[email protected]>
+
+        Fix crash when entering fullscreen during exit fullscreen animation.
+        https://bugs.webkit.org/show_bug.cgi?id=146117
+
+        Reviewed by Simon Fraser.
+
+        Because enterFullscreen can be called during exitFullscreen animation, the exit fullscreen teardown
+        should not imply a fullscreen state change on video element.
+
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::exitFullscreen): May be called from mainThread
+        (-[WebVideoFullscreenController exitFullscreen]): May be called from mainThread
+        * platform/ios/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::setVideoElement): 
+        Changing associated video element does not imply fullscreen mode change.
+
 2015-06-18  Brian J. Burg  <[email protected]>
 
         Web Inspector: improve generated types for objects passed to backend commands

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (185725 => 185726)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2015-06-18 23:35:24 UTC (rev 185725)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2015-06-18 23:38:55 UTC (rev 185726)
@@ -529,7 +529,7 @@
 
 void WebVideoFullscreenControllerContext::exitFullscreen()
 {
-    ASSERT(WebThreadIsCurrent());
+    ASSERT(WebThreadIsCurrent() || isMainThread());
     IntRect screenRect = m_videoElement->screenRect();
     RefPtr<WebVideoFullscreenControllerContext> strongThis(this);
     dispatch_async(dispatch_get_main_queue(), [strongThis, this, screenRect] {
@@ -577,7 +577,7 @@
 
 - (void)exitFullscreen
 {
-    ASSERT(WebThreadIsCurrent());
+    ASSERT(WebThreadIsCurrent() || isMainThread());
     _context->exitFullscreen();
 }
 

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm (185725 => 185726)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm	2015-06-18 23:35:24 UTC (rev 185725)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelVideoElement.mm	2015-06-18 23:38:55 UTC (rev 185726)
@@ -82,9 +82,6 @@
     if (m_videoFullscreenInterface)
         m_videoFullscreenInterface->resetMediaState();
 
-    if (m_videoElement && m_videoElement->fullscreenMode())
-        m_videoElement->fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenModeNone);
-
     if (m_videoElement && m_videoElement->videoFullscreenLayer())
         m_videoElement->setVideoFullscreenLayer(nullptr);
 

Modified: trunk/Source/WebKit2/ChangeLog (185725 => 185726)


--- trunk/Source/WebKit2/ChangeLog	2015-06-18 23:35:24 UTC (rev 185725)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-18 23:38:55 UTC (rev 185726)
@@ -1,3 +1,17 @@
+2015-06-18  Jeremy Jones  <[email protected]>
+
+        Fix crash when entering fullscreen during exit fullscreen animation.
+        https://bugs.webkit.org/show_bug.cgi?id=146117
+
+        Reviewed by Simon Fraser.
+
+        A partial teardown left the LayerHostingContext in a bad state when attempting to reuse the model and interface
+        objects. Instead, complete the teardown and don't reuse the objects.
+
+        * WebProcess/ios/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenManager::didEnterFullscreen): WebThreadRun is a no-op in WK2. Use dispatch_async.
+        (WebKit::WebVideoFullscreenManager::didCleanupFullscreen): Do complete teardown before entering fullscreen again.
+
 2015-06-18  Anders Carlsson  <[email protected]>
 
         Remove shouldInterruptJavaScript

Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm (185725 => 185726)


--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm	2015-06-18 23:35:24 UTC (rev 185725)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm	2015-06-18 23:38:55 UTC (rev 185726)
@@ -449,7 +449,7 @@
 
     // exit fullscreen now if it was previously requested during an animation.
     RefPtr<WebVideoFullscreenManager> strongThis(this);
-    WebThreadRun([strongThis, videoElement] {
+    dispatch_async(dispatch_get_main_queue(), [strongThis, videoElement] {
         strongThis->exitVideoFullscreenForVideoElement(*videoElement);
     });
 }
@@ -482,25 +482,22 @@
     interface->setIsAnimating(false);
     interface->setIsFullscreen(false);
     HTMLMediaElementEnums::VideoFullscreenMode mode = interface->fullscreenMode();
+    bool targetIsFullscreen = interface->targetIsFullscreen();
 
     model->setVideoFullscreenLayer(nil);
     RefPtr<HTMLVideoElement> videoElement = model->videoElement();
 
-    if (!interface->targetIsFullscreen()) {
-        model->setVideoElement(nullptr);
-        model->setWebVideoFullscreenInterface(nullptr);
-        interface->invalidate();
-        m_videoElements.remove(videoElement.get());
-        m_contextMap.remove(contextId);
-        return;
-    }
+    model->setVideoElement(nullptr);
+    model->setWebVideoFullscreenInterface(nullptr);
+    interface->invalidate();
+    m_videoElements.remove(videoElement.get());
+    m_contextMap.remove(contextId);
 
-    if (!videoElement)
+    if (!videoElement || !targetIsFullscreen)
         return;
 
-    // exit fullscreen now if it was previously requested during an animation.
     RefPtr<WebVideoFullscreenManager> strongThis(this);
-    WebThreadRun([strongThis, videoElement, mode] {
+    dispatch_async(dispatch_get_main_queue(), [strongThis, videoElement, mode] {
         strongThis->enterVideoFullscreenForVideoElement(*videoElement, mode);
     });
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to