Title: [253394] trunk/Source/WebKit
Revision
253394
Author
cdu...@apple.com
Date
2019-12-11 14:04:16 -0800 (Wed, 11 Dec 2019)

Log Message

[iOS] Issue load sooner on swipe back/forward navigation
https://bugs.webkit.org/show_bug.cgi?id=205127
<rdar://problem/57843862>

Reviewed by Tim Horton.

Issue load sooner on swipe back/forward navigation on iOS. We were waiting until the end of
the swipe animation to issue the load. We now issue the load as soon as the user lifts the finger
off the screen and thus commits to navigating. This results in improved perceived performance
when swiping back/forward to navigate.

* UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame):
(WebKit::ViewGestureController::willEndSwipeGesture):
* UIProcess/ViewGestureController.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::willEndSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (253393 => 253394)


--- trunk/Source/WebKit/ChangeLog	2019-12-11 21:47:39 UTC (rev 253393)
+++ trunk/Source/WebKit/ChangeLog	2019-12-11 22:04:16 UTC (rev 253394)
@@ -1,3 +1,25 @@
+2019-12-11  Chris Dumez  <cdu...@apple.com>
+
+        [iOS] Issue load sooner on swipe back/forward navigation
+        https://bugs.webkit.org/show_bug.cgi?id=205127
+        <rdar://problem/57843862>
+
+        Reviewed by Tim Horton.
+
+        Issue load sooner on swipe back/forward navigation on iOS. We were waiting until the end of
+        the swipe animation to issue the load. We now issue the load as soon as the user lifts the finger
+        off the screen and thus commits to navigating. This results in improved perceived performance
+        when swiping back/forward to navigate.
+
+        * UIProcess/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame):
+        (WebKit::ViewGestureController::willEndSwipeGesture):
+        * UIProcess/ViewGestureController.h:
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::willEndSwipeGesture):
+        (WebKit::ViewGestureController::endSwipeGesture):
+
 2019-12-11  Sihui Liu  <sihui_...@apple.com>
 
         IndexedDB: Introduce WebIDBServer class

Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.cpp (253393 => 253394)


--- trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2019-12-11 21:47:39 UTC (rev 253393)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2019-12-11 22:04:16 UTC (rev 253394)
@@ -163,6 +163,7 @@
 
 void ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame()
 {
+    m_didStartProvisionalLoad = true;
     m_snapshotRemovalTracker.resume();
 #if !PLATFORM(IOS_FAMILY)
     requestRenderTreeSizeNotificationIfNeeded();
@@ -565,6 +566,7 @@
         renderTreeSize = snapshot->renderTreeSize();
     auto renderTreeSizeThreshold = renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
 
+    m_didStartProvisionalLoad = false;
     m_webPageProxy.goToBackForwardItem(targetItem);
 
     auto* currentItem = m_webPageProxy.backForwardList().currentItem();

Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.h (253393 => 253394)


--- trunk/Source/WebKit/UIProcess/ViewGestureController.h	2019-12-11 21:47:39 UTC (rev 253393)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.h	2019-12-11 22:04:16 UTC (rev 253394)
@@ -137,6 +137,7 @@
     bool isNavigationSwipeGestureRecognizer(UIGestureRecognizer *) const;
     void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
     void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection);
+    void willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled);
     void endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *, bool cancelled);
     void willCommitPostSwipeTransitionLayerTree(bool);
     void setRenderTreeSize(uint64_t);
@@ -430,6 +431,7 @@
 #endif
 
     bool m_isConnectedToProcess { false };
+    bool m_didStartProvisionalLoad { false };
 
     SnapshotRemovalTracker m_snapshotRemovalTracker;
     WTF::Function<void()> m_loadCallback;

Modified: trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm (253393 => 253394)


--- trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm	2019-12-11 21:47:39 UTC (rev 253393)
+++ trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm	2019-12-11 22:04:16 UTC (rev 253394)
@@ -259,7 +259,7 @@
     [m_swipeTransitionContext _setTransitionIsInFlight:YES];
     [m_swipeTransitionContext _setInteractiveUpdateHandler:^(BOOL finish, CGFloat percent, BOOL transitionCompleted, _UIViewControllerTransitionContext *) {
         if (finish)
-            m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureWillEnd(transitionCompleted, *targetItem);
+            willEndSwipeGesture(*targetItem, !transitionCompleted);
     }];
     auto pageID = m_webPageProxy.identifier();
     GestureID gestureID = m_currentGestureID;
@@ -272,6 +272,43 @@
     [transition startInteractiveTransition:m_swipeTransitionContext.get()];
 }
 
+void ViewGestureController::willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled)
+{
+    m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureWillEnd(!cancelled, targetItem);
+
+    if (cancelled)
+        return;
+
+    m_snapshotRemovalTargetRenderTreeSize = 0;
+    if (ViewSnapshot* snapshot = targetItem.snapshot())
+        m_snapshotRemovalTargetRenderTreeSize = snapshot->renderTreeSize() * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
+
+    m_didStartProvisionalLoad = false;
+    m_webPageProxyForBackForwardListForCurrentSwipe->goToBackForwardItem(targetItem);
+
+    auto* currentItem = m_webPageProxyForBackForwardListForCurrentSwipe->backForwardList().currentItem();
+    // The main frame will not be navigated so hide the snapshot right away.
+    if (currentItem && currentItem->itemIsClone(targetItem)) {
+        removeSwipeSnapshot();
+        return;
+    }
+
+    // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
+    m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
+        | SnapshotRemovalTracker::RepaintAfterNavigation
+        | SnapshotRemovalTracker::MainFrameLoad
+        | SnapshotRemovalTracker::SubresourceLoads
+        | SnapshotRemovalTracker::ScrollPositionRestoration
+        | SnapshotRemovalTracker::SwipeAnimationEnd, [this] {
+        this->removeSwipeSnapshot();
+    });
+
+    if (ViewSnapshot* snapshot = targetItem.snapshot()) {
+        m_backgroundColorForCurrentSnapshot = snapshot->backgroundColor();
+        m_webPageProxy.didChangeBackgroundColor();
+    }
+}
+
 void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *context, bool cancelled)
 {
     [context _setTransitionIsInFlight:NO];
@@ -295,46 +332,22 @@
         return;
     }
 
-    m_snapshotRemovalTargetRenderTreeSize = 0;
-    if (ViewSnapshot* snapshot = targetItem->snapshot())
-        m_snapshotRemovalTargetRenderTreeSize = snapshot->renderTreeSize() * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
+    m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::SwipeAnimationEnd);
 
     m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidEnd(true, *targetItem);
     if (&m_webPageProxy != m_webPageProxyForBackForwardListForCurrentSwipe)
         m_webPageProxy.navigationGestureDidEnd();
 
-    m_webPageProxyForBackForwardListForCurrentSwipe->goToBackForwardItem(*targetItem);
-
-    if (!m_webPageProxy.drawingArea()) {
+    if (!m_webPageProxy.provisionalDrawingArea()) {
         removeSwipeSnapshot();
         return;
     }
 
-    auto* currentItem = m_webPageProxyForBackForwardListForCurrentSwipe->backForwardList().currentItem();
-    // The main frame will not be navigated so hide the snapshot right away.
-    if (currentItem && currentItem->itemIsClone(*targetItem)) {
-        removeSwipeSnapshot();
-        return;
-    }
-
-    // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
-    m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
-        | SnapshotRemovalTracker::RepaintAfterNavigation
-        | SnapshotRemovalTracker::MainFrameLoad
-        | SnapshotRemovalTracker::SubresourceLoads
-        | SnapshotRemovalTracker::ScrollPositionRestoration, [this] {
-            this->removeSwipeSnapshot();
-    });
-
-    if (ViewSnapshot* snapshot = targetItem->snapshot()) {
-        m_backgroundColorForCurrentSnapshot = snapshot->backgroundColor();
-        m_webPageProxy.didChangeBackgroundColor();
-    }
-
     auto pageID = m_webPageProxy.identifier();
     GestureID gestureID = m_currentGestureID;
-    m_loadCallback = [this, pageID, gestureID] {
-        auto drawingArea = m_webPageProxy.provisionalDrawingArea();
+
+    auto doAfterLoadStart = [this, pageID, gestureID] {
+        auto* drawingArea = m_webPageProxy.provisionalDrawingArea();
         if (!drawingArea) {
             removeSwipeSnapshot();
             return;
@@ -346,6 +359,11 @@
         });
         drawingArea->hideContentUntilPendingUpdate();
     };
+
+    if (m_didStartProvisionalLoad)
+        doAfterLoadStart();
+    else
+        m_loadCallback = WTFMove(doAfterLoadStart);
 }
 
 void ViewGestureController::setRenderTreeSize(uint64_t renderTreeSize)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to