Title: [271479] trunk
Revision
271479
Author
[email protected]
Date
2021-01-13 22:31:21 -0800 (Wed, 13 Jan 2021)

Log Message

REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
https://bugs.webkit.org/show_bug.cgi?id=220602
<rdar://problem/70402593>

Reviewed by Wenson Hsieh.

Source/WebKit:

No new tests; we are unable to API test video full-screen because of the lack of UIApp;
I have written a stand-alone test app that can reliably reproduce before this patch
and not afterwards.

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::scheduleActivityStateUpdate):
We can't call dispatchActivityStateChange directly underneath a post-commit callback,
because it has side-effects (like un-parenting the full-screen window) that may result
in other frameworks (e.g. UIKit) trying to install commit handlers for the same phase,
which is not allowed.

To fix this, add a dispatch_async; we _only_ care that the activity state change
doesn't apply until after the active commit is complete.

Tools:

* TestWebKitAPI/PlatformWebView.h:
Mark PlatformWebView noncopyable, since it is effectively noncopyable
(at least, the macOS implementation will overrelease the view if you
copy it, whoops).

* TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm:
(TestWebKitAPI::TEST):
Add a matching dispatch_async, or this test fails.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271478 => 271479)


--- trunk/Source/WebKit/ChangeLog	2021-01-14 04:28:24 UTC (rev 271478)
+++ trunk/Source/WebKit/ChangeLog	2021-01-14 06:31:21 UTC (rev 271479)
@@ -1,3 +1,26 @@
+2021-01-13  Tim Horton  <[email protected]>
+
+        REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
+        https://bugs.webkit.org/show_bug.cgi?id=220602
+        <rdar://problem/70402593>
+
+        Reviewed by Wenson Hsieh.
+
+        No new tests; we are unable to API test video full-screen because of the lack of UIApp;
+        I have written a stand-alone test app that can reliably reproduce before this patch
+        and not afterwards.
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::scheduleActivityStateUpdate):
+        We can't call dispatchActivityStateChange directly underneath a post-commit callback,
+        because it has side-effects (like un-parenting the full-screen window) that may result
+        in other frameworks (e.g. UIKit) trying to install commit handlers for the same phase,
+        which is not allowed.
+
+        To fix this, add a dispatch_async; we _only_ care that the activity state change
+        doesn't apply until after the active commit is complete.
+
+
 2021-01-13  Chris Dumez  <[email protected]>
 
         REGRESSION(r270961): Flipgrid can no longer capture video

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (271478 => 271479)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-01-14 04:28:24 UTC (rev 271478)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-01-14 06:31:21 UTC (rev 271479)
@@ -505,11 +505,16 @@
     // then schedule dispatch on runloop observer to collect changes in the same runloop cycle before dispatching.
     if (hasActiveCATransaction) {
         [CATransaction addCommitHandler:[weakThis = makeWeakPtr(*this)] {
-            auto protectedThis = makeRefPtr(weakThis.get());
-            if (!protectedThis)
-                return;
+            // We can't call dispatchActivityStateChange directly underneath this commit handler, because it has side-effects
+            // that may result in other frameworks trying to install commit handlers for the same phase, which is not allowed.
+            // So, dispatch_async here; we only care that the activity state change doesn't apply until after the active commit is complete.
+            dispatch_async(dispatch_get_main_queue(), [weakThis] {
+                auto protectedThis = makeRefPtr(weakThis.get());
+                if (!protectedThis)
+                    return;
 
-            protectedThis->dispatchActivityStateChange();
+                protectedThis->dispatchActivityStateChange();
+            });
         } forPhase:kCATransactionPhasePostCommit];
         return;
     }

Modified: trunk/Tools/ChangeLog (271478 => 271479)


--- trunk/Tools/ChangeLog	2021-01-14 04:28:24 UTC (rev 271478)
+++ trunk/Tools/ChangeLog	2021-01-14 06:31:21 UTC (rev 271479)
@@ -1,3 +1,20 @@
+2021-01-13  Tim Horton  <[email protected]>
+
+        REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos
+        https://bugs.webkit.org/show_bug.cgi?id=220602
+        <rdar://problem/70402593>
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/PlatformWebView.h:
+        Mark PlatformWebView noncopyable, since it is effectively noncopyable
+        (at least, the macOS implementation will overrelease the view if you
+        copy it, whoops).
+
+        * TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm:
+        (TestWebKitAPI::TEST):
+        Add a matching dispatch_async, or this test fails.
+
 2021-01-13  Alex Christensen  <[email protected]>
 
         Remove deprecated script and stylesheet SPI, replaced with more inclusively-named SPI

Modified: trunk/Tools/TestWebKitAPI/PlatformWebView.h (271478 => 271479)


--- trunk/Tools/TestWebKitAPI/PlatformWebView.h	2021-01-14 04:28:24 UTC (rev 271478)
+++ trunk/Tools/TestWebKitAPI/PlatformWebView.h	2021-01-14 06:31:21 UTC (rev 271479)
@@ -27,6 +27,7 @@
 #define PlatformWebView_h
 
 #include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
 
 #if USE(CG)
 #include <CoreGraphics/CGGeometry.h>
@@ -69,6 +70,7 @@
 
 class PlatformWebView {
     WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(PlatformWebView);
 public:
     explicit PlatformWebView(WKPageConfigurationRef);
     explicit PlatformWebView(WKContextRef, WKPageGroupRef = 0);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm (271478 => 271479)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm	2021-01-14 04:28:24 UTC (rev 271478)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm	2021-01-14 06:31:21 UTC (rev 271479)
@@ -75,7 +75,14 @@
 
     [wkView endDeferringViewInWindowChanges];
 
-    EXPECT_JS_TRUE(webView.page(), "document.hidden");
+    __block bool done = false;
+    WKPageRef page = webView.page();
+    dispatch_async(dispatch_get_main_queue(), ^{
+        EXPECT_JS_TRUE(page, "document.hidden");
+        done = true;
+    });
+
+    Util::run(&done);
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to