Title: [286719] branches/safari-612.4.2.1-branch/Source/WebCore
Revision
286719
Author
alanc...@apple.com
Date
2021-12-08 13:25:44 -0800 (Wed, 08 Dec 2021)

Log Message

Cherry-pick r286411. rdar://problem/85928816

    Scrolling complex websites can stutter: scrolling thread frame can fail to process wheel events
    https://bugs.webkit.org/show_bug.cgi?id=233739
    rdar://85946176

    Reviewed by Tim Horton.

    While the scrolling thread is chilling in
    ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), waiting up to half a
    frame to allow the main thread to handle the commit (for scroll synchronization), wheel
    events may have been dispatched to the scrolling thread.

    If we blow the timeout and commit anyway, we need to make sure we've handled these wheel
    events first, so that the current frame can commit some layer movement. We can achieve this
    by dispatching the applyLayerPositions(), which will enqueue it behind any waiting wheel
    event dispatch from EventDispatcher::internalWheelEvent().

    * page/scrolling/ScrollingTree.cpp:
    (WebCore::ScrollingTree::applyLayerPositions):
    * page/scrolling/ThreadedScrollingTree.cpp:
    (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286411 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog (286718 => 286719)


--- branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog	2021-12-08 21:25:41 UTC (rev 286718)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog	2021-12-08 21:25:44 UTC (rev 286719)
@@ -1,3 +1,53 @@
+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
+    https://bugs.webkit.org/show_bug.cgi?id=233739
+    rdar://85946176
+    
+    Reviewed by Tim Horton.
+    
+    While the scrolling thread is chilling in
+    ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), waiting up to half a
+    frame to allow the main thread to handle the commit (for scroll synchronization), wheel
+    events may have been dispatched to the scrolling thread.
+    
+    If we blow the timeout and commit anyway, we need to make sure we've handled these wheel
+    events first, so that the current frame can commit some layer movement. We can achieve this
+    by dispatching the applyLayerPositions(), which will enqueue it behind any waiting wheel
+    event dispatch from EventDispatcher::internalWheelEvent().
+    
+    * page/scrolling/ScrollingTree.cpp:
+    (WebCore::ScrollingTree::applyLayerPositions):
+    * page/scrolling/ThreadedScrollingTree.cpp:
+    (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-12-01  Simon Fraser  <simon.fra...@apple.com>
+
+            Scrolling complex websites can stutter: scrolling thread frame can fail to process wheel events
+            https://bugs.webkit.org/show_bug.cgi?id=233739
+            rdar://85946176
+
+            Reviewed by Tim Horton.
+
+            While the scrolling thread is chilling in
+            ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), waiting up to half a
+            frame to allow the main thread to handle the commit (for scroll synchronization), wheel
+            events may have been dispatched to the scrolling thread.
+
+            If we blow the timeout and commit anyway, we need to make sure we've handled these wheel
+            events first, so that the current frame can commit some layer movement. We can achieve this
+            by dispatching the applyLayerPositions(), which will enqueue it behind any waiting wheel
+            event dispatch from EventDispatcher::internalWheelEvent().
+
+            * page/scrolling/ScrollingTree.cpp:
+            (WebCore::ScrollingTree::applyLayerPositions):
+            * page/scrolling/ThreadedScrollingTree.cpp:
+            (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
+
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r286352. rdar://problem/85928816

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ScrollingTree.cpp (286718 => 286719)


--- branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ScrollingTree.cpp	2021-12-08 21:25:41 UTC (rev 286718)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ScrollingTree.cpp	2021-12-08 21:25:44 UTC (rev 286719)
@@ -416,7 +416,6 @@
 
 void ScrollingTree::applyLayerPositions()
 {
-    ASSERT(isMainThread());
     Locker locker { m_treeLock };
 
     applyLayerPositionsInternal();

Modified: branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (286718 => 286719)


--- branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2021-12-08 21:25:41 UTC (rev 286718)
+++ branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2021-12-08 21:25:44 UTC (rev 286719)
@@ -337,8 +337,12 @@
         m_state = SynchronizationState::Desynchronized;
         // At this point we know the main thread is taking too long in the rendering update,
         // so we give up trying to sync with the main thread and update layers here on the scrolling thread.
-        if (canUpdateLayersOnScrollingThread())
-            applyLayerPositionsInternal();
+        if (canUpdateLayersOnScrollingThread()) {
+            // Dispatch to allow for the scrolling thread to handle any outstanding wheel events before we commit layers.
+            ScrollingThread::dispatch([protectedThis = makeRef(*this)]() {
+                protectedThis->applyLayerPositions();
+            });
+        }
         tracePoint(ScrollingThreadRenderUpdateSyncEnd, 1);
     } else
         tracePoint(ScrollingThreadRenderUpdateSyncEnd);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to