Diff
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (275888 => 275889)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2021-04-13 16:50:38 UTC (rev 275889)
@@ -422,6 +422,8 @@
if (!m_rootNode)
return;
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::applyLayerPositionsInternal - main thread " << isMainThread());
+
applyLayerPositionsRecursive(*m_rootNode);
}
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (275888 => 275889)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-04-13 16:50:38 UTC (rev 275889)
@@ -210,11 +210,17 @@
return;
}
- 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));
+ if (m_hasScheduledNextRenderingUpdate) {
+ LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidScroll " << node.scrollingNodeID() << " to " << scrollPosition << " - rendering update already scheduled");
+ return;
+ }
+
+ LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidScroll " << node.scrollingNodeID() << " to " << scrollPosition << " bouncing to main thread");
+
+ m_hasScheduledNextRenderingUpdate = true;
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())
@@ -274,8 +280,15 @@
{
ASSERT(isMainThread());
- if (!hasProcessedWheelEventsRecently())
+ {
+ LockHolder treeLocker(m_treeMutex);
+ m_hasScheduledNextRenderingUpdate = false;
+ }
+
+ if (!hasProcessedWheelEventsRecently()) {
+ LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::willStartRenderingUpdate - no recent events");
return;
+ }
tracePoint(ScrollingThreadRenderUpdateSyncStart);
@@ -371,6 +384,8 @@
LockHolder treeLocker(m_treeMutex);
+ LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::displayDidRefreshOnScrollingThread - hasScheduledNextRenderingUpdate " << m_hasScheduledNextRenderingUpdate);
+
if (m_state != SynchronizationState::Idle && canUpdateLayersOnScrollingThread())
applyLayerPositionsInternal();
@@ -388,7 +403,7 @@
}
}
-void ThreadedScrollingTree::displayDidRefresh(PlatformDisplayID displayID)
+void ThreadedScrollingTree::displayDidRefresh(PlatformDisplayID displayID, ShouldSyncWithMainThread)
{
// We're on the EventDispatcher thread or in the ThreadedCompositor thread here.
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (275888 => 275889)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2021-04-13 16:50:38 UTC (rev 275889)
@@ -37,6 +37,11 @@
class AsyncScrollingCoordinator;
+enum class ShouldSyncWithMainThread : bool {
+ No,
+ Yes
+};
+
// The ThreadedScrollingTree class lives almost exclusively on the scrolling thread and manages the
// hierarchy of scrollable regions on the page. It's also responsible for dispatching events
// to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
@@ -55,7 +60,7 @@
void invalidate() override;
- WEBCORE_EXPORT void displayDidRefresh(PlatformDisplayID);
+ WEBCORE_EXPORT void displayDidRefresh(PlatformDisplayID, ShouldSyncWithMainThread);
void willStartRenderingUpdate();
void didCompleteRenderingUpdate();
@@ -114,6 +119,7 @@
bool m_scrollAnimatorEnabled { false };
bool m_hasNodesWithSynchronousScrollingReasons { false };
+ bool m_hasScheduledNextRenderingUpdate { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/AnimationFrameRate.h (275888 => 275889)
--- trunk/Source/WebCore/platform/graphics/AnimationFrameRate.h 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebCore/platform/graphics/AnimationFrameRate.h 2021-04-13 16:50:38 UTC (rev 275889)
@@ -45,14 +45,14 @@
};
// Allow a little more than 60fps to make sure we can at least hit that frame rate.
-constexpr const Seconds FullSpeedAnimationInterval { 15_ms };
+constexpr const Seconds FullSpeedAnimationInterval { 31_ms };
// Allow a little more than 30fps to make sure we can at least hit that frame rate.
-constexpr const Seconds HalfSpeedThrottlingAnimationInterval { 30_ms };
+constexpr const Seconds HalfSpeedThrottlingAnimationInterval { 60_ms };
constexpr const Seconds AggressiveThrottlingAnimationInterval { 10_s };
constexpr const int IntervalThrottlingFactor { 2 };
-constexpr const FramesPerSecond FullSpeedFramesPerSecond = 60;
-constexpr const FramesPerSecond HalfSpeedThrottlingFramesPerSecond = 30;
+constexpr const FramesPerSecond FullSpeedFramesPerSecond = 30;
+constexpr const FramesPerSecond HalfSpeedThrottlingFramesPerSecond = 15;
WEBCORE_EXPORT FramesPerSecond framesPerSecondNearestFullSpeed(FramesPerSecond);
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (275888 => 275889)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2021-04-13 16:50:38 UTC (rev 275889)
@@ -279,12 +279,12 @@
}
#endif
-void EventDispatcher::notifyScrollingTreesDisplayWasRefreshed(PlatformDisplayID displayID)
+void EventDispatcher::notifyScrollingTreesDisplayWasRefreshed(PlatformDisplayID displayID, bool shouldSyncWithMainThread)
{
#if ENABLE(SCROLLING_THREAD)
LockHolder locker(m_scrollingTreesMutex);
for (auto keyValuePair : m_scrollingTrees)
- keyValuePair.value->displayDidRefresh(displayID);
+ keyValuePair.value->displayDidRefresh(displayID, shouldSyncWithMainThread ? ShouldSyncWithMainThread::Yes : ShouldSyncWithMainThread::No);
#endif
}
@@ -292,8 +292,9 @@
void EventDispatcher::displayWasRefreshed(PlatformDisplayID displayID, const DisplayUpdate& displayUpdate, bool sendToMainThread)
{
ASSERT(!RunLoop::isMain());
- notifyScrollingTreesDisplayWasRefreshed(displayID);
+ notifyScrollingTreesDisplayWasRefreshed(displayID, sendToMainThread);
+ // FIXME: We need ensure that the last update in a sequence always has "send to main thread".
if (!sendToMainThread)
return;
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h (275888 => 275889)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2021-04-13 16:47:53 UTC (rev 275888)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2021-04-13 16:50:38 UTC (rev 275889)
@@ -74,7 +74,7 @@
void initializeConnection(IPC::Connection*);
- void notifyScrollingTreesDisplayWasRefreshed(WebCore::PlatformDisplayID);
+ void notifyScrollingTreesDisplayWasRefreshed(WebCore::PlatformDisplayID, bool shouldSyncWithMainThread = true);
private:
EventDispatcher();