⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 253394 in webkit


Ignore:
Timestamp:
Dec 11, 2019, 2:04:16 PM (7 years ago)
Author:
Chris Dumez
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):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r253393 r253394  
     12019-12-11  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Issue load sooner on swipe back/forward navigation
     4        https://bugs.webkit.org/show_bug.cgi?id=205127
     5        <rdar://problem/57843862>
     6
     7        Reviewed by Tim Horton.
     8
     9        Issue load sooner on swipe back/forward navigation on iOS. We were waiting until the end of
     10        the swipe animation to issue the load. We now issue the load as soon as the user lifts the finger
     11        off the screen and thus commits to navigating. This results in improved perceived performance
     12        when swiping back/forward to navigate.
     13
     14        * UIProcess/ViewGestureController.cpp:
     15        (WebKit::ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame):
     16        (WebKit::ViewGestureController::willEndSwipeGesture):
     17        * UIProcess/ViewGestureController.h:
     18        * UIProcess/ios/ViewGestureControllerIOS.mm:
     19        (WebKit::ViewGestureController::beginSwipeGesture):
     20        (WebKit::ViewGestureController::willEndSwipeGesture):
     21        (WebKit::ViewGestureController::endSwipeGesture):
     22
    1232019-12-11  Sihui Liu  <sihui_liu@apple.com>
    224
  • trunk/Source/WebKit/UIProcess/ViewGestureController.cpp

    r253360 r253394  
    164164void ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame()
    165165{
     166    m_didStartProvisionalLoad = true;
    166167    m_snapshotRemovalTracker.resume();
    167168#if !PLATFORM(IOS_FAMILY)
    … …  
    566567    auto renderTreeSizeThreshold = renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
    567568
     569    m_didStartProvisionalLoad = false;
    568570    m_webPageProxy.goToBackForwardItem(targetItem);
    569571
  • trunk/Source/WebKit/UIProcess/ViewGestureController.h

    r253360 r253394  
    138138    void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
    139139    void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection);
     140    void willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled);
    140141    void endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *, bool cancelled);
    141142    void willCommitPostSwipeTransitionLayerTree(bool);
    … …  
    431432
    432433    bool m_isConnectedToProcess { false };
     434    bool m_didStartProvisionalLoad { false };
    433435
    434436    SnapshotRemovalTracker m_snapshotRemovalTracker;
  • trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm

    r253076 r253394  
    260260    [m_swipeTransitionContext _setInteractiveUpdateHandler:^(BOOL finish, CGFloat percent, BOOL transitionCompleted, _UIViewControllerTransitionContext *) {
    261261        if (finish)
    262             m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureWillEnd(transitionCompleted, *targetItem);
     262            willEndSwipeGesture(*targetItem, !transitionCompleted);
    263263    }];
    264264    auto pageID = m_webPageProxy.identifier();
    … …  
    271271    [transition setAnimationController:animationController.get()];
    272272    [transition startInteractiveTransition:m_swipeTransitionContext.get()];
     273}
     274
     275void ViewGestureController::willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled)
     276{
     277    m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureWillEnd(!cancelled, targetItem);
     278
     279    if (cancelled)
     280        return;
     281
     282    m_snapshotRemovalTargetRenderTreeSize = 0;
     283    if (ViewSnapshot* snapshot = targetItem.snapshot())
     284        m_snapshotRemovalTargetRenderTreeSize = snapshot->renderTreeSize() * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
     285
     286    m_didStartProvisionalLoad = false;
     287    m_webPageProxyForBackForwardListForCurrentSwipe->goToBackForwardItem(targetItem);
     288
     289    auto* currentItem = m_webPageProxyForBackForwardListForCurrentSwipe->backForwardList().currentItem();
     290    // The main frame will not be navigated so hide the snapshot right away.
     291    if (currentItem && currentItem->itemIsClone(targetItem)) {
     292        removeSwipeSnapshot();
     293        return;
     294    }
     295
     296    // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
     297    m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
     298        | SnapshotRemovalTracker::RepaintAfterNavigation
     299        | SnapshotRemovalTracker::MainFrameLoad
     300        | SnapshotRemovalTracker::SubresourceLoads
     301        | SnapshotRemovalTracker::ScrollPositionRestoration
     302        | SnapshotRemovalTracker::SwipeAnimationEnd, [this] {
     303        this->removeSwipeSnapshot();
     304    });
     305
     306    if (ViewSnapshot* snapshot = targetItem.snapshot()) {
     307        m_backgroundColorForCurrentSnapshot = snapshot->backgroundColor();
     308        m_webPageProxy.didChangeBackgroundColor();
     309    }
    273310}
    274311
    … …  
    296333    }
    297334
    298     m_snapshotRemovalTargetRenderTreeSize = 0;
    299     if (ViewSnapshot* snapshot = targetItem->snapshot())
    300         m_snapshotRemovalTargetRenderTreeSize = snapshot->renderTreeSize() * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
     335    m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::SwipeAnimationEnd);
    301336
    302337    m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidEnd(true, *targetItem);
    … …  
    304339        m_webPageProxy.navigationGestureDidEnd();
    305340
    306     m_webPageProxyForBackForwardListForCurrentSwipe->goToBackForwardItem(*targetItem);
    307 
    308     if (!m_webPageProxy.drawingArea()) {
     341    if (!m_webPageProxy.provisionalDrawingArea()) {
    309342        removeSwipeSnapshot();
    310343        return;
    311     }
    312 
    313     auto* currentItem = m_webPageProxyForBackForwardListForCurrentSwipe->backForwardList().currentItem();
    314     // The main frame will not be navigated so hide the snapshot right away.
    315     if (currentItem && currentItem->itemIsClone(*targetItem)) {
    316         removeSwipeSnapshot();
    317         return;
    318     }
    319 
    320     // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
    321     m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
    322         | SnapshotRemovalTracker::RepaintAfterNavigation
    323         | SnapshotRemovalTracker::MainFrameLoad
    324         | SnapshotRemovalTracker::SubresourceLoads
    325         | SnapshotRemovalTracker::ScrollPositionRestoration, [this] {
    326             this->removeSwipeSnapshot();
    327     });
    328 
    329     if (ViewSnapshot* snapshot = targetItem->snapshot()) {
    330         m_backgroundColorForCurrentSnapshot = snapshot->backgroundColor();
    331         m_webPageProxy.didChangeBackgroundColor();
    332344    }
    333345
    334346    auto pageID = m_webPageProxy.identifier();
    335347    GestureID gestureID = m_currentGestureID;
    336     m_loadCallback = [this, pageID, gestureID] {
    337         auto drawingArea = m_webPageProxy.provisionalDrawingArea();
     348
     349    auto doAfterLoadStart = [this, pageID, gestureID] {
     350        auto* drawingArea = m_webPageProxy.provisionalDrawingArea();
    338351        if (!drawingArea) {
    339352            removeSwipeSnapshot();
    … …  
    347360        drawingArea->hideContentUntilPendingUpdate();
    348361    };
     362
     363    if (m_didStartProvisionalLoad)
     364        doAfterLoadStart();
     365    else
     366        m_loadCallback = WTFMove(doAfterLoadStart);
    349367}
    350368
Note: See TracChangeset for help on using the changeset viewer.