Changeset 185972 in webkit


Ignore:
Timestamp:
Jun 25, 2015 5:29:58 PM (9 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Swiping back just after scrolling can cause some tiles to disappear
https://bugs.webkit.org/show_bug.cgi?id=146329
rdar://problem/21233010

Reviewed by Tim Horton.
Source/WebCore:

Have the Compositing log channel dump the visible rect used for layer flushing.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::flushPendingLayerChanges):

Source/WebKit2:

When doing a back swipe, views interposed between the WKWebView and the WKContentView
get positions and animations for the swipe. This -_updateVisibleContentRects to
compute bad visible and unobscured rects, so we lose tiles.

Fix by "freezing" the visible and unobscured content rects in the view being
swiped for the duration of the navigation gesture. When swiping the main view,
we just plumb through navigationGestureDidEnd(). When Reader is showing and the
swiped view is different from the navigating view, use the new navigationGestureDidEnd()
override which takes no arguments.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _updateVisibleContentRects]):
(-[WKWebView _navigationGestureDidBegin]):
(-[WKWebView _navigationGestureDidEnd]):

  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::navigationGestureDidEnd):

  • UIProcess/API/gtk/PageClientImpl.h:
  • UIProcess/CoordinatedGraphics/WebView.h:
  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::navigationGestureDidEnd):

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::navigationGestureDidBegin):
(WebKit::PageClientImpl::navigationGestureDidEnd):

  • UIProcess/ios/ViewGestureControllerIOS.mm:

(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):

  • UIProcess/mac/PageClientImpl.h:
  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::navigationGestureDidEnd):

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185971 r185972  
     12015-06-25  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Swiping back just after scrolling can cause some tiles to disappear
     4        https://bugs.webkit.org/show_bug.cgi?id=146329
     5        rdar://problem/21233010
     6
     7        Reviewed by Tim Horton.
     8
     9        Have the Compositing log channel dump the visible rect used for layer flushing.
     10
     11        * rendering/RenderLayerCompositor.cpp:
     12        (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
     13
    1142015-06-25  Brent Fulgham  <bfulgham@apple.com>
    215
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r185762 r185972  
    468468    if (GraphicsLayer* rootLayer = rootGraphicsLayer()) {
    469469#if PLATFORM(IOS)
    470         rootLayer->flushCompositingState(frameView.exposedContentRect());
     470        FloatRect exposedRect = frameView.exposedContentRect();
     471        LOG(Compositing, "RenderLayerCompositor %p flushPendingLayerChanges(%d) %.2f, %.2f, %.2fx%.2f", this, isFlushRoot,
     472            exposedRect.x(), exposedRect.y(), exposedRect.width(), exposedRect.height());
     473        rootLayer->flushCompositingState(exposedRect);
    471474#else
    472475        // Having a m_clipLayer indicates that we're doing scrolling via GraphicsLayers.
     
    474477        if (!frameView.exposedRect().isInfinite())
    475478            visibleRect.intersect(IntRect(frameView.exposedRect()));
     479
     480        LOG(Compositing, "RenderLayerCompositor %p flushPendingLayerChanges(%d) %d, %d, %dx%d", this, isFlushRoot,
     481            visibleRect.x(), visibleRect.y(), visibleRect.width(), visibleRect.height());
    476482        rootLayer->flushCompositingState(visibleRect);
    477483#endif
  • trunk/Source/WebKit2/ChangeLog

    r185968 r185972  
     12015-06-25  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Swiping back just after scrolling can cause some tiles to disappear
     4        https://bugs.webkit.org/show_bug.cgi?id=146329
     5        rdar://problem/21233010
     6
     7        Reviewed by Tim Horton.
     8       
     9        When doing a back swipe, views interposed between the WKWebView and the WKContentView
     10        get positions and animations for the swipe. This -_updateVisibleContentRects to
     11        compute bad visible and unobscured rects, so we lose tiles.
     12       
     13        Fix by "freezing" the visible and unobscured content rects in the view being
     14        swiped for the duration of the navigation gesture. When swiping the main view,
     15        we just plumb through navigationGestureDidEnd(). When Reader is showing and the
     16        swiped view is different from the navigating view, use the new navigationGestureDidEnd()
     17        override which takes no arguments.
     18
     19        * UIProcess/API/Cocoa/WKWebView.mm:
     20        (-[WKWebView _updateVisibleContentRects]):
     21        (-[WKWebView _navigationGestureDidBegin]):
     22        (-[WKWebView _navigationGestureDidEnd]):
     23        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     24        * UIProcess/API/gtk/PageClientImpl.cpp:
     25        (WebKit::PageClientImpl::navigationGestureDidEnd):
     26        * UIProcess/API/gtk/PageClientImpl.h:
     27        * UIProcess/CoordinatedGraphics/WebView.h:
     28        * UIProcess/PageClient.h:
     29        * UIProcess/WebPageProxy.cpp:
     30        (WebKit::WebPageProxy::navigationGestureDidEnd):
     31        * UIProcess/WebPageProxy.h:
     32        * UIProcess/ios/PageClientImplIOS.h:
     33        * UIProcess/ios/PageClientImplIOS.mm:
     34        (WebKit::PageClientImpl::navigationGestureDidBegin):
     35        (WebKit::PageClientImpl::navigationGestureDidEnd):
     36        * UIProcess/ios/ViewGestureControllerIOS.mm:
     37        (WebKit::ViewGestureController::beginSwipeGesture):
     38        (WebKit::ViewGestureController::endSwipeGesture):
     39        * UIProcess/mac/PageClientImpl.h:
     40        * UIProcess/mac/PageClientImpl.mm:
     41        (WebKit::PageClientImpl::navigationGestureDidEnd):
     42
    1432015-06-25  Joseph Pecoraro  <pecoraro@apple.com>
    244
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r185967 r185972  
    8484#import <wtf/MathExtras.h>
    8585#import <wtf/NeverDestroyed.h>
     86#import <wtf/Optional.h>
    8687#import <wtf/RetainPtr.h>
    8788
     
    190191    RetainPtr<UIView> _resizeAnimationView;
    191192    CGFloat _lastAdjustmentForScroller;
     193    Optional<CGRect> _frozenVisibleContentRect;
     194    Optional<CGRect> _frozenUnobscuredContentRect;
    192195
    193196    BOOL _needsToRestoreExposedRect;
     
    15601563
    15611564    CGRect fullViewRect = self.bounds;
    1562     CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
     1565    CGRect visibleRectInContentCoordinates = _frozenVisibleContentRect ? _frozenVisibleContentRect.value() : [self convertRect:fullViewRect toView:_contentView.get()];
    15631566
    15641567    CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
    1565     CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
     1568    CGRect unobscuredRectInContentCoordinates = _frozenUnobscuredContentRect ? _frozenUnobscuredContentRect.value() : [self convertRect:unobscuredRect toView:_contentView.get()];
    15661569
    15671570    CGFloat scaleFactor = contentZoomScale(self);
     
    17111714}
    17121715
    1713 #endif
     1716- (void)_navigationGestureDidBegin
     1717{
     1718    // During a back/forward swipe, there's a view interposed between this view and the content view that has
     1719    // an offset and animation on it, which results in computing incorrect rectangles. Work around by using
     1720    // frozen rects during swipes.
     1721    CGRect fullViewRect = self.bounds;
     1722    CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
     1723
     1724    _frozenVisibleContentRect = [self convertRect:fullViewRect toView:_contentView.get()];
     1725    _frozenUnobscuredContentRect = [self convertRect:unobscuredRect toView:_contentView.get()];
     1726}
     1727
     1728- (void)_navigationGestureDidEnd
     1729{
     1730    _frozenVisibleContentRect = Nullopt;
     1731    _frozenUnobscuredContentRect = Nullopt;
     1732}
     1733
     1734#endif // PLATFORM(IOS)
    17141735
    17151736#pragma mark OS X-specific methods
     
    18011822    return [_wkView performDragOperation:sender];
    18021823}
    1803 #endif
     1824#endif // PLATFORM(MAC)
    18041825
    18051826@end
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h

    r185727 r185972  
    104104- (void)_updateScrollViewBackground;
    105105
     106- (void)_navigationGestureDidBegin;
     107- (void)_navigationGestureDidEnd;
     108
    106109@property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
    107110#else
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r185415 r185972  
    411411}
    412412
     413void PageClientImpl::navigationGestureDidEnd()
     414{
     415}
     416
    413417void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem&)
    414418{
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

    r185415 r185972  
    123123    virtual void navigationGestureWillEnd(bool, WebBackForwardListItem&) override;
    124124    virtual void navigationGestureDidEnd(bool, WebBackForwardListItem&) override;
     125    virtual void navigationGestureDidEnd() override;
    125126    virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
    126127
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h

    r183517 r185972  
    204204    virtual void navigationGestureWillEnd(bool, WebBackForwardListItem&) override { };
    205205    virtual void navigationGestureDidEnd(bool, WebBackForwardListItem&) override { };
     206    virtual void navigationGestureDidEnd() override { };
    206207    virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override { };
    207208
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r185415 r185972  
    308308    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) = 0;
    309309    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) = 0;
     310    virtual void navigationGestureDidEnd() = 0;
    310311    virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) = 0;
    311312
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r185929 r185972  
    57475747}
    57485748
     5749void WebPageProxy::navigationGestureDidEnd()
     5750{
     5751    m_pageClient.navigationGestureDidEnd();
     5752}
     5753
    57495754void WebPageProxy::willRecordNavigationSnapshot(WebBackForwardListItem& item)
    57505755{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r185929 r185972  
    10121012    void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
    10131013    void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
     1014    void navigationGestureDidEnd();
    10141015    void navigationGestureSnapshotWasRemoved();
    10151016    void willRecordNavigationSnapshot(WebBackForwardListItem&);
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r183517 r185972  
    176176    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
    177177    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
     178    virtual void navigationGestureDidEnd() override;
    178179    virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
    179180
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r185727 r185972  
    686686void PageClientImpl::navigationGestureDidBegin()
    687687{
     688    [m_webView _navigationGestureDidBegin];
    688689    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
    689690}
     
    697698{
    698699    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
     700    [m_webView _navigationGestureDidEnd];
     701}
     702
     703void PageClientImpl::navigationGestureDidEnd()
     704{
     705    [m_webView _navigationGestureDidEnd];
    699706}
    700707
  • trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm

    r185967 r185972  
    185185    m_webPageProxyForBackForwardListForCurrentSwipe = m_alternateBackForwardListSourceView.get() ? m_alternateBackForwardListSourceView.get()->_page : &m_webPageProxy;
    186186    m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidBegin();
     187    if (&m_webPageProxy != m_webPageProxyForBackForwardListForCurrentSwipe)
     188        m_webPageProxy.navigationGestureDidBegin();
    187189
    188190    auto& backForwardList = m_webPageProxyForBackForwardListForCurrentSwipe->backForwardList();
     
    286288        removeSwipeSnapshot();
    287289        webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidEnd(false, *targetItem);
     290        if (&m_webPageProxy != webPageProxyForBackForwardListForCurrentSwipe)
     291            m_webPageProxy.navigationGestureDidEnd();
    288292        return;
    289293    }
     
    294298
    295299    m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidEnd(true, *targetItem);
     300    if (&m_webPageProxy != m_webPageProxyForBackForwardListForCurrentSwipe)
     301        m_webPageProxy.navigationGestureDidEnd();
     302
    296303    m_webPageProxyForBackForwardListForCurrentSwipe->goToBackForwardItem(targetItem);
    297304
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r184780 r185972  
    187187    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
    188188    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
     189    virtual void navigationGestureDidEnd() override;
    189190    virtual void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
    190191
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r185229 r185972  
    766766}
    767767
     768void PageClientImpl::navigationGestureDidEnd()
     769{
     770}
     771
    768772void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
    769773{
Note: See TracChangeset for help on using the changeset viewer.