Title: [278970] trunk/Source
Revision
278970
Author
s...@apple.com
Date
2021-06-16 17:46:41 -0700 (Wed, 16 Jun 2021)

Log Message

takeSnapshotWithConfiguration() should wait for the next flush before it does callSnapshotRect()
https://bugs.webkit.org/show_bug.cgi?id=226257
<rdar://76411685>

Reviewed by Simon Fraser and Tim Horton.

Source/WebCore/PAL:

* pal/spi/cocoa/QuartzCoreSPI.h:

Source/WebKit:

This will ensure the latest IOSurfaces are pushed to backboardd before
taking the snapshot. Also we need create an implicit transaction to ensure
a commit will happen.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (278969 => 278970)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-06-17 00:27:58 UTC (rev 278969)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-06-17 00:46:41 UTC (rev 278970)
@@ -1,3 +1,13 @@
+2021-06-16  Said Abou-Hallawa  <s...@apple.com>
+
+        takeSnapshotWithConfiguration() should wait for the next flush before it does callSnapshotRect()
+        https://bugs.webkit.org/show_bug.cgi?id=226257
+        <rdar://76411685>
+
+        Reviewed by Simon Fraser and Tim Horton.
+
+        * pal/spi/cocoa/QuartzCoreSPI.h:
+
 2021-06-15  Jonathan Bedard  <jbed...@apple.com>
 
         [iOS 15] Support building WebKit

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h (278969 => 278970)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h	2021-06-17 00:27:58 UTC (rev 278969)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h	2021-06-17 00:46:41 UTC (rev 278970)
@@ -144,6 +144,7 @@
 
 @interface CATransaction ()
 + (void)addCommitHandler:(void(^)(void))block forPhase:(CATransactionPhase)phase;
++ (void)activate;
 + (CATransactionPhase)currentPhase;
 + (void)synchronize;
 + (uint32_t)currentState;

Modified: trunk/Source/WebKit/ChangeLog (278969 => 278970)


--- trunk/Source/WebKit/ChangeLog	2021-06-17 00:27:58 UTC (rev 278969)
+++ trunk/Source/WebKit/ChangeLog	2021-06-17 00:46:41 UTC (rev 278970)
@@ -1,3 +1,18 @@
+2021-06-16  Said Abou-Hallawa  <s...@apple.com>
+
+        takeSnapshotWithConfiguration() should wait for the next flush before it does callSnapshotRect()
+        https://bugs.webkit.org/show_bug.cgi?id=226257
+        <rdar://76411685>
+
+        Reviewed by Simon Fraser and Tim Horton.
+
+        This will ensure the latest IOSurfaces are pushed to backboardd before
+        taking the snapshot. Also we need create an implicit transaction to ensure
+        a commit will happen.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+
 2021-06-16  Mark Lam  <mark....@apple.com>
 
         Adopt com.apple.security.cs.jit-write-allowlist on internal builds.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (278969 => 278970)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-06-17 00:27:58 UTC (rev 278969)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-06-17 00:46:41 UTC (rev 278970)
@@ -1218,13 +1218,20 @@
         return;
     }
 
-    _page->callAfterNextPresentationUpdate([callSnapshotRect = WTFMove(callSnapshotRect), handler](WebKit::CallbackBase::Error error) {
+    _page->callAfterNextPresentationUpdate([callSnapshotRect = WTFMove(callSnapshotRect), handler](WebKit::CallbackBase::Error error) mutable {
         if (error != WebKit::CallbackBase::Error::None) {
             tracePoint(TakeSnapshotEnd, snapshotFailedTraceValue);
             handler(nil, createNSError(WKErrorUnknown).get());
             return;
         }
-        callSnapshotRect();
+
+        // Create an implicit transaction to ensure a commit will happen next.
+        [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();
+        } forPhase:kCATransactionPhasePostCommit];
     });
 #endif
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to