Swipe snapshot stays up too long swiping around on apple.com (waiting for first paint)
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 21:41:29 +0000 (21:41 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 21:41:29 +0000 (21:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192319
<rdar://problem/45928708>

Reviewed by Simon Fraser.

* UIProcess/Cocoa/ViewGestureController.cpp:
(WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):
* UIProcess/Cocoa/ViewGestureController.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::endSwipeGesture):
In r236966, I reverted slightly too much of r232416.
We still need to defer requesting a presentation update callback until
after the provisional load starts. Otherwise, we could get the callback
while we're in the 'paused' state, and drop it on the floor. That would
then mean that we time out instead of promptly removing the snapshot.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp
Source/WebKit/UIProcess/Cocoa/ViewGestureController.h
Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm

index 4906483..5f35946 100644 (file)
@@ -1,3 +1,22 @@
+2018-12-03  Tim Horton  <timothy_horton@apple.com>
+
+        Swipe snapshot stays up too long swiping around on apple.com (waiting for first paint)
+        https://bugs.webkit.org/show_bug.cgi?id=192319
+        <rdar://problem/45928708>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/Cocoa/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):
+        * UIProcess/Cocoa/ViewGestureController.h:
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::endSwipeGesture):
+        In r236966, I reverted slightly too much of r232416.
+        We still need to defer requesting a presentation update callback until
+        after the provisional load starts. Otherwise, we could get the callback
+        while we're in the 'paused' state, and drop it on the floor. That would
+        then mean that we time out instead of promptly removing the snapshot.
+
 2018-12-03  Alex Christensen  <achristensen@webkit.org>
 
         Update process assertions after swapping processes
index 2d795e7..d4faa93 100644 (file)
@@ -148,6 +148,9 @@ bool ViewGestureController::canSwipeInDirection(SwipeDirection direction) const
 void ViewGestureController::didStartProvisionalLoadForMainFrame()
 {
     m_snapshotRemovalTracker.resume();
+
+    if (auto provisionalLoadCallback = WTFMove(m_provisionalLoadCallback))
+        provisionalLoadCallback();
 }
 
 void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
index a77d345..3fd2994 100644 (file)
@@ -312,6 +312,7 @@ private:
     bool m_isConnectedToProcess { false };
 
     SnapshotRemovalTracker m_snapshotRemovalTracker;
+    WTF::Function<void()> m_provisionalLoadCallback;
 };
 
 } // namespace WebKit
index 320648b..0d3711f 100644 (file)
@@ -300,19 +300,6 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
         return;
     }
 
-    if (auto drawingArea = m_webPageProxy.drawingArea()) {
-        uint64_t pageID = m_webPageProxy.pageID();
-        GestureID gestureID = m_currentGestureID;
-        drawingArea->dispatchAfterEnsuringDrawing([pageID, gestureID] (CallbackBase::Error error) {
-            if (auto gestureController = controllerForGesture(pageID, gestureID))
-                gestureController->willCommitPostSwipeTransitionLayerTree(error == CallbackBase::Error::None);
-        });
-        drawingArea->hideContentUntilPendingUpdate();
-    } else {
-        removeSwipeSnapshot();
-        return;
-    }
-
     // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
     m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
         | SnapshotRemovalTracker::RepaintAfterNavigation
@@ -326,6 +313,22 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
         m_backgroundColorForCurrentSnapshot = snapshot->backgroundColor();
         m_webPageProxy.didChangeBackgroundColor();
     }
+
+    uint64_t pageID = m_webPageProxy.pageID();
+    GestureID gestureID = m_currentGestureID;
+    m_provisionalLoadCallback = [this, pageID, gestureID] {
+        auto drawingArea = m_webPageProxy.drawingArea();
+        if (!drawingArea) {
+            removeSwipeSnapshot();
+            return;
+        }
+
+        drawingArea->dispatchAfterEnsuringDrawing([pageID, gestureID] (CallbackBase::Error error) {
+            if (auto gestureController = controllerForGesture(pageID, gestureID))
+                gestureController->willCommitPostSwipeTransitionLayerTree(error == CallbackBase::Error::None);
+        });
+        drawingArea->hideContentUntilPendingUpdate();
+    };
 }
 
 void ViewGestureController::setRenderTreeSize(uint64_t renderTreeSize)