Title: [279229] branches/safari-612.1.20-branch/Source/WebKit
Revision
279229
Author
rubent...@apple.com
Date
2021-06-24 08:49:31 -0700 (Thu, 24 Jun 2021)

Log Message

Cherry-pick r279210. rdar://problem/79726355

    REGRESSION(r278970): A CATransaction commitHandler should not execute a client callback
    https://bugs.webkit.org/show_bug.cgi?id=227318
    <rdar://79625962>

    Reviewed by Tim Horton.

    In takeSnapshotWithConfiguration() we call callSnapshotRect() inside the
    callback of [CATransaction addCommitHandler].

    callSnapshotRect() calls the client callback which may call directly or
    indirectly addCommitHandler. But it is prohibited by CA to add a commit
    handler while processing a registered commit handler.

    The fix is to postpone calling callSnapshotRect() till CATransaction
    processes all its commit handler callbacks.

    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):

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

Modified Paths

Diff

Modified: branches/safari-612.1.20-branch/Source/WebKit/ChangeLog (279228 => 279229)


--- branches/safari-612.1.20-branch/Source/WebKit/ChangeLog	2021-06-24 15:37:44 UTC (rev 279228)
+++ branches/safari-612.1.20-branch/Source/WebKit/ChangeLog	2021-06-24 15:49:31 UTC (rev 279229)
@@ -1,3 +1,50 @@
+2021-06-24  Kocsen Chung  <kocsen_ch...@apple.com>
+
+        Cherry-pick r279210. rdar://problem/79726355
+
+    REGRESSION(r278970): A CATransaction commitHandler should not execute a client callback
+    https://bugs.webkit.org/show_bug.cgi?id=227318
+    <rdar://79625962>
+    
+    Reviewed by Tim Horton.
+    
+    In takeSnapshotWithConfiguration() we call callSnapshotRect() inside the
+    callback of [CATransaction addCommitHandler].
+    
+    callSnapshotRect() calls the client callback which may call directly or
+    indirectly addCommitHandler. But it is prohibited by CA to add a commit
+    handler while processing a registered commit handler.
+    
+    The fix is to postpone calling callSnapshotRect() till CATransaction
+    processes all its commit handler callbacks.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-06-23  Said Abou-Hallawa  <s...@apple.com>
+
+            REGRESSION(r278970): A CATransaction commitHandler should not execute a client callback
+            https://bugs.webkit.org/show_bug.cgi?id=227318
+            <rdar://79625962>
+
+            Reviewed by Tim Horton.
+
+            In takeSnapshotWithConfiguration() we call callSnapshotRect() inside the
+            callback of [CATransaction addCommitHandler].
+
+            callSnapshotRect() calls the client callback which may call directly or
+            indirectly addCommitHandler. But it is prohibited by CA to add a commit
+            handler while processing a registered commit handler.
+
+            The fix is to postpone calling callSnapshotRect() till CATransaction
+            processes all its commit handler callbacks.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+
 2021-06-20  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Rename WKVisualSearchPreviewController to WKQuickLookPreviewController

Modified: branches/safari-612.1.20-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (279228 => 279229)


--- branches/safari-612.1.20-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-06-24 15:37:44 UTC (rev 279228)
+++ branches/safari-612.1.20-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-06-24 15:49:31 UTC (rev 279229)
@@ -1241,8 +1241,13 @@
         [CATransaction activate];
 
         // Wait for the next flush to ensure the latest IOSurfaces are pushed to backboardd before taking the snapshot.
-        [CATransaction addCommitHandler:[callSnapshotRect = WTFMove(callSnapshotRect)] {
-            callSnapshotRect();
+        [CATransaction addCommitHandler:[callSnapshotRect = WTFMove(callSnapshotRect)]() mutable {
+            // callSnapshotRect() calls the client callback which may call directly or indirectly addCommitHandler.
+            // It is prohibited by CA to add a commit handler while processing a registered commit handler.
+            // So postpone calling callSnapshotRect() till CATransaction processes its commit handlers.
+            dispatch_async(dispatch_get_main_queue(), [callSnapshotRect = WTFMove(callSnapshotRect)] {
+                callSnapshotRect();
+            });
         } forPhase:kCATransactionPhasePostCommit];
     });
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to