Title: [214391] trunk/Source/WebKit2
Revision
214391
Author
[email protected]
Date
2017-03-24 18:04:32 -0700 (Fri, 24 Mar 2017)

Log Message

[iOS WK2] Move from a pre-commit handler to dispatch_async for visible content rect updates
https://bugs.webkit.org/show_bug.cgi?id=170091
rdar://problem/30682584

Reviewed by Tim Horton.

[CATransaction addCommitHandler:forPhase:] is sometimes not called when running inside another
commit callback (rdar://problem/31253952), and we don't yet have a reliable way to detect this.

So dispatch_async() to postpone the call to [CATransaction addCommitHandler:forPhase:] to a known-
good time.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (214390 => 214391)


--- trunk/Source/WebKit2/ChangeLog	2017-03-25 00:39:20 UTC (rev 214390)
+++ trunk/Source/WebKit2/ChangeLog	2017-03-25 01:04:32 UTC (rev 214391)
@@ -1,3 +1,20 @@
+2017-03-24  Simon Fraser  <[email protected]>
+
+        [iOS WK2] Move from a pre-commit handler to dispatch_async for visible content rect updates
+        https://bugs.webkit.org/show_bug.cgi?id=170091
+        rdar://problem/30682584
+
+        Reviewed by Tim Horton.
+        
+        [CATransaction addCommitHandler:forPhase:] is sometimes not called when running inside another
+        commit callback (rdar://problem/31253952), and we don't yet have a reliable way to detect this.
+
+        So dispatch_async() to postpone the call to [CATransaction addCommitHandler:forPhase:] to a known-
+        good time.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
+
 2017-03-24  John Wilander  <[email protected]>
 
         Re-enable the network process' keychain access to fix client certificate authentication

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (214390 => 214391)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-03-25 00:39:20 UTC (rev 214390)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-03-25 01:04:32 UTC (rev 214391)
@@ -288,7 +288,7 @@
 
     RetainPtr<WKPasswordView> _passwordView;
 
-    BOOL _hasInstalledPreCommitHandlerForVisibleRectUpdate;
+    BOOL _hasScheduledVisibleRectUpdate;
     BOOL _visibleContentRectUpdateScheduledFromScrollViewInStableState;
     Vector<BlockPtr<void ()>> _visibleContentRectUpdateCallbacks;
 #endif
@@ -2301,16 +2301,19 @@
 {
     _visibleContentRectUpdateScheduledFromScrollViewInStableState = [self _scrollViewIsInStableState:scrollView];
 
-    if (_hasInstalledPreCommitHandlerForVisibleRectUpdate)
+    if (_hasScheduledVisibleRectUpdate)
         return;
 
-    _hasInstalledPreCommitHandlerForVisibleRectUpdate = YES;
-
-    [CATransaction addCommitHandler:[retainedSelf = retainPtr(self)] {
-        WKWebView *webView = retainedSelf.get();
-        [webView _updateVisibleContentRects];
-        webView->_hasInstalledPreCommitHandlerForVisibleRectUpdate = NO;
-    } forPhase:kCATransactionPhasePreCommit];
+    _hasScheduledVisibleRectUpdate = YES;
+    
+    // FIXME: remove the dispatch_async() when we have a fix for rdar://problem/31253952.
+    dispatch_async(dispatch_get_main_queue(), [retainedSelf = retainPtr(self)] {
+        [CATransaction addCommitHandler:[retainedSelf] {
+            WKWebView *webView = retainedSelf.get();
+            [webView _updateVisibleContentRects];
+            webView->_hasScheduledVisibleRectUpdate = NO;
+        } forPhase:kCATransactionPhasePreCommit];
+    });
 }
 
 static bool scrollViewCanScroll(UIScrollView *scrollView)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to