Changeset 262094 in webkit


Ignore:
Timestamp:
May 22, 2020 9:23:48 PM (4 years ago)
Author:
Simon Fraser
Message:

Stuttery overflow scrolling in slow-scrolling regions (facebook messenger, feedly.com)
https://bugs.webkit.org/show_bug.cgi?id=212291
<rdar://problem/61940624>

Reviewed by Tim Horton.

Now that we do scrolling tree commits on the main thread, ThreadedScrollingTree::scrollingTreeNodeDidScroll()
can be called on the main thread. In this case, don't do an RunLoop::main().dispatch() which introduces
asynchrony; just call into the ScrollingCoordinator synchronously.

Do some minor refactoring to move noteScrollingThreadSyncCompleteForNode() into updateScrollPositionAfterAsyncScroll().

Hard to test because it involves scrolling thread/main thread interactions.

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::synchronizeStateFromScrollingTree):
(WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):

  • page/scrolling/AsyncScrollingCoordinator.h:
  • page/scrolling/ThreadedScrollingTree.cpp:

(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r262093 r262094  
     12020-05-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Stuttery overflow scrolling in slow-scrolling regions (facebook messenger, feedly.com)
     4        https://bugs.webkit.org/show_bug.cgi?id=212291
     5        <rdar://problem/61940624>
     6
     7        Reviewed by Tim Horton.
     8
     9        Now that we do scrolling tree commits on the main thread, ThreadedScrollingTree::scrollingTreeNodeDidScroll()
     10        can be called on the main thread. In this case, don't do an RunLoop::main().dispatch() which introduces
     11        asynchrony; just call into the ScrollingCoordinator synchronously.
     12
     13        Do some minor refactoring to move noteScrollingThreadSyncCompleteForNode() into updateScrollPositionAfterAsyncScroll().
     14
     15        Hard to test because it involves scrolling thread/main thread interactions.
     16
     17        * page/scrolling/AsyncScrollingCoordinator.cpp:
     18        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
     19        (WebCore::AsyncScrollingCoordinator::synchronizeStateFromScrollingTree):
     20        (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
     21        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
     22        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
     23        * page/scrolling/AsyncScrollingCoordinator.h:
     24        * page/scrolling/ThreadedScrollingTree.cpp:
     25        (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
     26
    1272020-05-22  Zalan Bujtas  <zalan@apple.com>
    228
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r261985 r262094  
    265265    bool inProgrammaticScroll = scrollableArea.currentScrollType() == ScrollType::Programmatic;
    266266    if (inProgrammaticScroll || inBackForwardCache)
    267         updateScrollPositionAfterAsyncScroll(scrollingNodeID, scrollPosition, { }, ScrollType::Programmatic, ScrollingLayerPositionAction::Set);
     267        updateScrollPositionAfterAsyncScroll(scrollingNodeID, scrollPosition, { }, ScrollType::Programmatic, ScrollingLayerPositionAction::Set, InformWheelEventMonitor::No);
    268268
    269269    ASSERT(inProgrammaticScroll == (scrollType == ScrollType::Programmatic));
     
    300300        if (scrollPosition && scrolledSinceLastCommit) {
    301301            LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::synchronizeStateFromScrollingTree - node " << nodeID << " scroll position " << scrollPosition);
    302             updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition.value(), layoutViewportOrigin, ScrollType::User, ScrollingLayerPositionAction::Set);
     302            updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition.value(), layoutViewportOrigin, ScrollType::User, ScrollingLayerPositionAction::Set, InformWheelEventMonitor::No);
    303303        }
    304304    });
     
    332332        updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, ScrollType::User, m_scheduledScrollUpdate.updateLayerPositionAction);
    333333        updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, ScrollType::User, scrollingLayerPositionAction);
    334        
    335         if (m_scheduledScrollUpdate.nodeID != nodeID)
    336             noteScrollingThreadSyncCompleteForNode(m_scheduledScrollUpdate.nodeID);
    337         noteScrollingThreadSyncCompleteForNode(nodeID);
    338334        return;
    339335    }
     
    346342{
    347343    updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, ScrollType::User, m_scheduledScrollUpdate.updateLayerPositionAction);
    348     noteScrollingThreadSyncCompleteForNode(m_scheduledScrollUpdate.nodeID);
    349344}
    350345
     
    381376}
    382377
    383 void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, ScrollType scrollType, ScrollingLayerPositionAction scrollingLayerPositionAction)
     378void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, ScrollType scrollType, ScrollingLayerPositionAction scrollingLayerPositionAction, InformWheelEventMonitor informWheelEventMonitor)
    384379{
    385380    ASSERT(isMainThread());
     381
     382    if (informWheelEventMonitor == InformWheelEventMonitor::Yes)
     383        noteScrollingThreadSyncCompleteForNode(scrollingNodeID);
    386384
    387385    if (!m_page)
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r261985 r262094  
    5454    WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction);
    5555
     56    enum class InformWheelEventMonitor { Yes, No };
     57    void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, ScrollType, ScrollingLayerPositionAction, InformWheelEventMonitor = InformWheelEventMonitor::Yes);
     58
    5659#if PLATFORM(COCOA)
    5760    WEBCORE_EXPORT void handleWheelEventPhase(ScrollingNodeID, PlatformWheelEventPhase) final;
     
    7780
    7881    RefPtr<ScrollingTree> releaseScrollingTree() { return WTFMove(m_scrollingTree); }
    79 
    80     void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, ScrollType, ScrollingLayerPositionAction);
    8182
    8283    WEBCORE_EXPORT String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const override;
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp

    r262046 r262094  
    149149    LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidScroll " << node.scrollingNodeID() << " to " << scrollPosition << " bouncing to main thread");
    150150
     151    if (RunLoop::isMain()) {
     152        m_scrollingCoordinator->updateScrollPositionAfterAsyncScroll(node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, ScrollType::User, scrollingLayerPositionAction);
     153        return;
     154    }
     155
    151156    RunLoop::main().dispatch([strongThis = makeRef(*this), nodeID = node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction] {
    152157        if (auto* scrollingCoordinator = strongThis->m_scrollingCoordinator.get())
Note: See TracChangeset for help on using the changeset viewer.