Title: [286720] branches/safari-612.4.2.1-branch/Source/WebCore
- Revision
- 286720
- Author
- alanc...@apple.com
- Date
- 2021-12-08 13:25:47 -0800 (Wed, 08 Dec 2021)
Log Message
Cherry-pick r286410. rdar://problem/85928816
Scrolling complex websites can stutter: scrolling thread commit can get blocked on scroll synchronization
https://bugs.webkit.org/show_bug.cgi?id=233738
rdar://85880147
Reviewed by Tim Horton.
The scroll synchronization added in r261985 can cause dropped frames while scrolling. This
occurs when ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), which is
called at the start of a rendering update on the main thread, starts at a time when it will
delay the handling of displayDidRefreshOnScrollingThread(). This can result in delaying the
CA commit for that frame on the scrolling thread.
The solution is to clamp the duration that waitForRenderingUpdateCompletionOrTimeout() waits
on the condition, so that it doesn't exceed the next expected display refresh time.
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
(WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
* page/scrolling/ThreadedScrollingTree.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog (286719 => 286720)
--- branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog 2021-12-08 21:25:44 UTC (rev 286719)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog 2021-12-08 21:25:47 UTC (rev 286720)
@@ -1,5 +1,53 @@
2021-12-02 Russell Epstein <repst...@apple.com>
+ Cherry-pick r286410. rdar://problem/85928816
+
+ Scrolling complex websites can stutter: scrolling thread commit can get blocked on scroll synchronization
+ https://bugs.webkit.org/show_bug.cgi?id=233738
+ rdar://85880147
+
+ Reviewed by Tim Horton.
+
+ The scroll synchronization added in r261985 can cause dropped frames while scrolling. This
+ occurs when ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), which is
+ called at the start of a rendering update on the main thread, starts at a time when it will
+ delay the handling of displayDidRefreshOnScrollingThread(). This can result in delaying the
+ CA commit for that frame on the scrolling thread.
+
+ The solution is to clamp the duration that waitForRenderingUpdateCompletionOrTimeout() waits
+ on the condition, so that it doesn't exceed the next expected display refresh time.
+
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
+ (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
+ * page/scrolling/ThreadedScrollingTree.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-12-01 Simon Fraser <simon.fra...@apple.com>
+
+ Scrolling complex websites can stutter: scrolling thread commit can get blocked on scroll synchronization
+ https://bugs.webkit.org/show_bug.cgi?id=233738
+ rdar://85880147
+
+ Reviewed by Tim Horton.
+
+ The scroll synchronization added in r261985 can cause dropped frames while scrolling. This
+ occurs when ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), which is
+ called at the start of a rendering update on the main thread, starts at a time when it will
+ delay the handling of displayDidRefreshOnScrollingThread(). This can result in delaying the
+ CA commit for that frame on the scrolling thread.
+
+ The solution is to clamp the duration that waitForRenderingUpdateCompletionOrTimeout() waits
+ on the condition, so that it doesn't exceed the next expected display refresh time.
+
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
+ (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
+ * page/scrolling/ThreadedScrollingTree.h:
+
+2021-12-02 Russell Epstein <repst...@apple.com>
+
Cherry-pick r286411. rdar://problem/85928816
Scrolling complex websites can stutter: scrolling thread frame can fail to process wheel events
Modified: branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (286719 => 286720)
--- branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-12-08 21:25:44 UTC (rev 286719)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2021-12-08 21:25:47 UTC (rev 286720)
@@ -323,8 +323,9 @@
if (m_delayedRenderingUpdateDetectionTimer)
m_delayedRenderingUpdateDetectionTimer->stop();
- auto startTime = MonotonicTime::now();
- auto timeoutTime = startTime + maxAllowableRenderingUpdateDurationForSynchronization();
+ auto currentTime = MonotonicTime::now();
+ auto estimatedNextDisplayRefreshTime = std::max(m_lastDisplayDidRefreshTime + frameDuration(), currentTime);
+ auto timeoutTime = std::min(currentTime + maxAllowableRenderingUpdateDurationForSynchronization(), estimatedNextDisplayRefreshTime);
bool becameIdle = m_stateCondition.waitUntil(m_treeLock, timeoutTime, [&] {
assertIsHeld(m_treeLock);
@@ -386,6 +387,10 @@
ASSERT(ScrollingThread::isCurrentThread());
Locker locker { m_treeLock };
+
+ auto now = MonotonicTime::now();
+ m_lastDisplayDidRefreshTime = now;
+ serviceScrollAnimations();
if (m_state != SynchronizationState::Idle && canUpdateLayersOnScrollingThread())
applyLayerPositionsInternal();
Modified: branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (286719 => 286720)
--- branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2021-12-08 21:25:44 UTC (rev 286719)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2021-12-08 21:25:47 UTC (rev 286720)
@@ -109,6 +109,8 @@
bool m_receivedBeganEventFromMainThread WTF_GUARDED_BY_LOCK(m_treeLock) { false };
Condition m_waitingForBeganEventCondition;
+
+ MonotonicTime m_lastDisplayDidRefreshTime;
// Dynamically allocated because it has to use the ScrollingThread's runloop.
std::unique_ptr<RunLoop::Timer<ThreadedScrollingTree>> m_delayedRenderingUpdateDetectionTimer WTF_GUARDED_BY_LOCK(m_treeLock);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes