Title: [265743] trunk/Source
- Revision
- 265743
- Author
- [email protected]
- Date
- 2020-08-16 13:16:29 -0700 (Sun, 16 Aug 2020)
Log Message
Scrolling sync changes in r261985 regressed CPU usage by ~2 ms/s
https://bugs.webkit.org/show_bug.cgi?id=215529
<rdar://problem/66866163>
Reviewed by Geoff Garen.
Source/WebCore:
r261985 added two code paths that wake up the scrolling thread on every
rendering update (triggered by displayDidRefresh()). One is a ping from
the EventDispatcher thread, the other is a wake-and-block from the main
thread. If the scrolling thread isn't active (no wheel events received recently),
we can avoid both of these to reduce the number of CPU core wakeups.
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::isRecentlyActive):
(WebCore::ScrollingTree::setRecentlyActive):
* page/scrolling/ScrollingTree.h:
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
(WebCore::ThreadedScrollingTree::displayDidRefresh):
Source/WebKit:
r261985 added two code paths that wake up the scrolling thread on every
rendering update (triggered by displayDidRefresh()). One is a ping from
the EventDispatcher thread, the other is a wake-and-block from the main
thread. If the scrolling thread isn't active (no wheel events received recently),
we can avoid both of these to reduce the number of CPU core wakeups.
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (265742 => 265743)
--- trunk/Source/WebCore/ChangeLog 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebCore/ChangeLog 2020-08-16 20:16:29 UTC (rev 265743)
@@ -1,3 +1,25 @@
+2020-08-14 Simon Fraser <[email protected]>
+
+ Scrolling sync changes in r261985 regressed CPU usage by ~2 ms/s
+ https://bugs.webkit.org/show_bug.cgi?id=215529
+ <rdar://problem/66866163>
+
+ Reviewed by Geoff Garen.
+
+ r261985 added two code paths that wake up the scrolling thread on every
+ rendering update (triggered by displayDidRefresh()). One is a ping from
+ the EventDispatcher thread, the other is a wake-and-block from the main
+ thread. If the scrolling thread isn't active (no wheel events received recently),
+ we can avoid both of these to reduce the number of CPU core wakeups.
+
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::isRecentlyActive):
+ (WebCore::ScrollingTree::setRecentlyActive):
+ * page/scrolling/ScrollingTree.h:
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
+ (WebCore::ThreadedScrollingTree::displayDidRefresh):
+
2020-08-16 Dean Jackson <[email protected]>
[AS Layout Tests] 6 WPT css-backgrounds tests consistently failing
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (265742 => 265743)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-08-16 20:16:29 UTC (rev 265743)
@@ -600,6 +600,20 @@
return m_treeState.displayID;
}
+bool ScrollingTree::hasProcessedWheelEventsRecently()
+{
+ LockHolder locker(m_lastWheelEventTimeMutex);
+ constexpr auto activityInterval = 50_ms; // Duration of a few frames so that we stay active for sequence of wheel events.
+
+ return (MonotonicTime::now() - m_lastWheelEventTime) < activityInterval;
+}
+
+void ScrollingTree::willProcessWheelEvent()
+{
+ LockHolder locker(m_lastWheelEventTimeMutex);
+ m_lastWheelEventTime = MonotonicTime::now();
+}
+
Optional<unsigned> ScrollingTree::nominalFramesPerSecond()
{
LockHolder locker(m_treeStateMutex);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (265742 => 265743)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-08-16 20:16:29 UTC (rev 265743)
@@ -207,6 +207,9 @@
void windowScreenDidChange(PlatformDisplayID, Optional<unsigned> nominalFramesPerSecond);
PlatformDisplayID displayID();
+
+ bool hasProcessedWheelEventsRecently();
+ WEBCORE_EXPORT void willProcessWheelEvent();
protected:
FloatPoint mainFrameScrollPosition() const;
@@ -271,6 +274,9 @@
Lock m_swipeStateMutex;
SwipeState m_swipeState;
+ Lock m_lastWheelEventTimeMutex;
+ MonotonicTime m_lastWheelEventTime;
+
protected:
bool m_allowLatching { true };
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (265742 => 265743)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-08-16 20:16:29 UTC (rev 265743)
@@ -204,6 +204,9 @@
{
ASSERT(isMainThread());
+ if (!hasProcessedWheelEventsRecently())
+ return;
+
tracePoint(ScrollingThreadRenderUpdateSyncStart);
// Wait for the scrolling thread to acquire m_treeMutex. This ensures that any pending wheel events are processed.
@@ -315,16 +318,17 @@
void ThreadedScrollingTree::displayDidRefresh(PlatformDisplayID displayID)
{
+ // We're on the EventDispatcher thread here.
+
if (displayID != this->displayID())
return;
+
+ if (!hasProcessedWheelEventsRecently())
+ return;
- // We're on the EventDispatcher thread here.
-
-#if ENABLE(SCROLLING_THREAD)
ScrollingThread::dispatch([protectedThis = makeRef(*this)]() {
protectedThis->displayDidRefreshOnScrollingThread();
});
-#endif
}
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (265742 => 265743)
--- trunk/Source/WebKit/ChangeLog 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebKit/ChangeLog 2020-08-16 20:16:29 UTC (rev 265743)
@@ -1,3 +1,20 @@
+2020-08-14 Simon Fraser <[email protected]>
+
+ Scrolling sync changes in r261985 regressed CPU usage by ~2 ms/s
+ https://bugs.webkit.org/show_bug.cgi?id=215529
+ <rdar://problem/66866163>
+
+ Reviewed by Geoff Garen.
+
+ r261985 added two code paths that wake up the scrolling thread on every
+ rendering update (triggered by displayDidRefresh()). One is a ping from
+ the EventDispatcher thread, the other is a wake-and-block from the main
+ thread. If the scrolling thread isn't active (no wheel events received recently),
+ we can avoid both of these to reduce the number of CPU core wakeups.
+
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::wheelEvent):
+
2020-08-15 Tim Horton <[email protected]>
Live Web Content processes do not respect accent color if dynamically changed to "multicolor"
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (265742 => 265743)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-08-16 19:11:06 UTC (rev 265742)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-08-16 20:16:29 UTC (rev 265743)
@@ -139,6 +139,8 @@
if (!processingSteps.contains(WheelEventProcessingSteps::ScrollingThread))
return false;
+ scrollingTree->willProcessWheelEvent();
+
ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, pageID, protectedThis = makeRef(*this)] {
auto result = scrollingTree->handleWheelEvent(platformWheelEvent);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes