Title: [271825] branches/safari-611-branch
Revision
271825
Author
alanc...@apple.com
Date
2021-01-25 14:11:17 -0800 (Mon, 25 Jan 2021)

Log Message

Cherry-pick r271479. rdar://problem/73469631

    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.

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

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (271824 => 271825)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:11:12 UTC (rev 271824)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:11:17 UTC (rev 271825)
@@ -1,5 +1,68 @@
 2021-01-25  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r271479. rdar://problem/73469631
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-13  Tim Horton  <timothy_hor...@apple.com>
+
+            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-25  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r271469. rdar://problem/73468174
 
     [Cocoa] Network extension sandbox extensions are sometimes issued too late

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (271824 => 271825)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-01-25 22:11:12 UTC (rev 271824)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-01-25 22:11:17 UTC (rev 271825)
@@ -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: branches/safari-611-branch/Tools/ChangeLog (271824 => 271825)


--- branches/safari-611-branch/Tools/ChangeLog	2021-01-25 22:11:12 UTC (rev 271824)
+++ branches/safari-611-branch/Tools/ChangeLog	2021-01-25 22:11:17 UTC (rev 271825)
@@ -1,3 +1,60 @@
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r271479. rdar://problem/73469631
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-13  Tim Horton  <timothy_hor...@apple.com>
+
+            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-09  Lauro Moura  <lmo...@igalia.com>
 
         [GStreamer] Build failure with gst-build: Missing gst/audio/audio.h

Modified: branches/safari-611-branch/Tools/TestWebKitAPI/PlatformWebView.h (271824 => 271825)


--- branches/safari-611-branch/Tools/TestWebKitAPI/PlatformWebView.h	2021-01-25 22:11:12 UTC (rev 271824)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/PlatformWebView.h	2021-01-25 22:11:17 UTC (rev 271825)
@@ -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: branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm (271824 => 271825)


--- branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm	2021-01-25 22:11:12 UTC (rev 271824)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKit/DeferredViewInWindowStateChange.mm	2021-01-25 22:11:17 UTC (rev 271825)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to