Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
scrollingTreeNodeDidScroll() should just trigger a rendering udpate
https://bugs.webkit.org/show_bug.cgi?id=224394

Reviewed by Tim Horton.

After handling wheel events on the scrolling thread,
ThreadedScrollingTree::scrollingTreeNodeDidScroll() appends to a queue of pending updates
and then triggers applyPendingScrollUpdates() on the main thread to process those updates.
However, every rendering update also processes pending scroll updates via
synchronizeStateFromScrollingTree(), so it's simpler if we just trigger a rendering update.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::scrollingThreadAddedPendingUpdate):
(WebCore::AsyncScrollingCoordinator::scheduleRenderingUpdate):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
* page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp:
(WebCore::ScrollingCoordinatorNicosia::scheduleTreeStateCommit):


Canonical link: https://commits.webkit.org/236361@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Apr 10, 2021
1 parent 78249d4 commit c4fe229
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
24 changes: 24 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
2021-04-09 Simon Fraser <simon.fraser@apple.com>

scrollingTreeNodeDidScroll() should just trigger a rendering udpate
https://bugs.webkit.org/show_bug.cgi?id=224394

Reviewed by Tim Horton.

After handling wheel events on the scrolling thread,
ThreadedScrollingTree::scrollingTreeNodeDidScroll() appends to a queue of pending updates
and then triggers applyPendingScrollUpdates() on the main thread to process those updates.
However, every rendering update also processes pending scroll updates via
synchronizeStateFromScrollingTree(), so it's simpler if we just trigger a rendering update.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::scrollingThreadAddedPendingUpdate):
(WebCore::AsyncScrollingCoordinator::scheduleRenderingUpdate):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::scheduleTreeStateCommit):
* page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp:
(WebCore::ScrollingCoordinatorNicosia::scheduleTreeStateCommit):

2021-04-09 Jean-Yves Avenard <jya@apple.com>

Media Session action should default to the MediaElement's default when no MediaSession handler are set
Expand Down
10 changes: 10 additions & 0 deletions Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Expand Up @@ -69,6 +69,11 @@ void AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged()
scheduleTreeStateCommit();
}

void AsyncScrollingCoordinator::scrollingThreadAddedPendingUpdate()
{
scheduleRenderingUpdate();
}

#if PLATFORM(COCOA)
void AsyncScrollingCoordinator::handleWheelEventPhase(ScrollingNodeID nodeID, PlatformWheelEventPhase phase)
{
Expand Down Expand Up @@ -305,6 +310,11 @@ void AsyncScrollingCoordinator::applyPendingScrollUpdates()
}
}

void AsyncScrollingCoordinator::scheduleRenderingUpdate()
{
m_page->scheduleRenderingUpdate(RenderingUpdateStep::ScrollingTreeUpdate);
}

FrameView* AsyncScrollingCoordinator::frameViewForScrollingNode(ScrollingNodeID scrollingNodeID) const
{
if (!m_scrollingStateTree->rootStateNode())
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Expand Up @@ -50,6 +50,7 @@ class AsyncScrollingCoordinator : public ScrollingCoordinator {
ScrollingTree* scrollingTree() const { return m_scrollingTree.get(); }

void scrollingStateTreePropertiesChanged();
void scrollingThreadAddedPendingUpdate();

void applyPendingScrollUpdates();

Expand Down Expand Up @@ -87,6 +88,7 @@ class AsyncScrollingCoordinator : public ScrollingCoordinator {
WEBCORE_EXPORT String scrollingTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const override;
WEBCORE_EXPORT void willCommitTree() override;
void synchronizeStateFromScrollingTree();
void scheduleRenderingUpdate();

bool eventTrackingRegionsDirty() const { return m_eventTrackingRegionsDirty; }

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
Expand Up @@ -210,15 +210,15 @@ void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingTreeScrollingNod
return;
}

LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidScroll " << node.scrollingNodeID() << " to " << scrollPosition << " bouncing to main thread");
LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidScroll " << node.scrollingNodeID() << " to " << scrollPosition << " triggering main thread rendering update");

auto scrollUpdate = ScrollUpdate { node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction };
addPendingScrollUpdate(WTFMove(scrollUpdate));

auto deferrer = WheelEventTestMonitorCompletionDeferrer { wheelEventTestMonitor(), reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(node.scrollingNodeID()), WheelEventTestMonitor::ScrollingThreadSyncNeeded };
RunLoop::main().dispatch([strongThis = makeRef(*this), deferrer = WTFMove(deferrer)] {
if (auto* scrollingCoordinator = strongThis->m_scrollingCoordinator.get())
scrollingCoordinator->applyPendingScrollUpdates();
scrollingCoordinator->scrollingThreadAddedPendingUpdate();
});
}

Expand Down
3 changes: 1 addition & 2 deletions Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Expand Up @@ -102,8 +102,7 @@

void ScrollingCoordinatorMac::scheduleTreeStateCommit()
{
// FIXME: This one needs work.
m_page->scheduleRenderingUpdate(RenderingUpdateStep::ScrollingTreeUpdate);
scheduleRenderingUpdate();
}

void ScrollingCoordinatorMac::commitTreeStateIfNeeded()
Expand Down
Expand Up @@ -89,6 +89,7 @@ void ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread(const Platf

void ScrollingCoordinatorNicosia::scheduleTreeStateCommit()
{
// FIXME: This should probably just call scheduleRenderingUpdate().
if (!m_scrollingStateTreeCommitterTimer.isActive())
m_scrollingStateTreeCommitterTimer.startOneShot(0_s);
}
Expand Down

0 comments on commit c4fe229

Please sign in to comment.