⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286720 in webkit


Ignore:
Timestamp:
Dec 8, 2021, 1:25:47 PM (5 years ago)
Author:
Alan Coon
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

Location:
branches/safari-612.4.2.1-branch/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.4.2.1-branch/Source/WebCore/ChangeLog

    r286719 r286720  
     12021-12-02  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r286410. rdar://problem/85928816
     4
     5    Scrolling complex websites can stutter: scrolling thread commit can get blocked on scroll synchronization
     6    https://bugs.webkit.org/show_bug.cgi?id=233738
     7    rdar://85880147
     8   
     9    Reviewed by Tim Horton.
     10   
     11    The scroll synchronization added in r261985 can cause dropped frames while scrolling. This
     12    occurs when ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), which is
     13    called at the start of a rendering update on the main thread, starts at a time when it will
     14    delay the handling of displayDidRefreshOnScrollingThread(). This can result in delaying the
     15    CA commit for that frame on the scrolling thread.
     16   
     17    The solution is to clamp the duration that waitForRenderingUpdateCompletionOrTimeout() waits
     18    on the condition, so that it doesn't exceed the next expected display refresh time.
     19   
     20    * page/scrolling/ThreadedScrollingTree.cpp:
     21    (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
     22    (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
     23    * page/scrolling/ThreadedScrollingTree.h:
     24   
     25    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     26
     27    2021-12-01  Simon Fraser  <simon.fraser@apple.com>
     28
     29            Scrolling complex websites can stutter: scrolling thread commit can get blocked on scroll synchronization
     30            https://bugs.webkit.org/show_bug.cgi?id=233738
     31            rdar://85880147
     32
     33            Reviewed by Tim Horton.
     34
     35            The scroll synchronization added in r261985 can cause dropped frames while scrolling. This
     36            occurs when ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout(), which is
     37            called at the start of a rendering update on the main thread, starts at a time when it will
     38            delay the handling of displayDidRefreshOnScrollingThread(). This can result in delaying the
     39            CA commit for that frame on the scrolling thread.
     40
     41            The solution is to clamp the duration that waitForRenderingUpdateCompletionOrTimeout() waits
     42            on the condition, so that it doesn't exceed the next expected display refresh time.
     43
     44            * page/scrolling/ThreadedScrollingTree.cpp:
     45            (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
     46            (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
     47            * page/scrolling/ThreadedScrollingTree.h:
     48
    1492021-12-02  Russell Epstein  <repstein@apple.com>
    250
  • branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp

    r286719 r286720  
    324324        m_delayedRenderingUpdateDetectionTimer->stop();
    325325
    326     auto startTime = MonotonicTime::now();
    327     auto timeoutTime = startTime + maxAllowableRenderingUpdateDurationForSynchronization();
     326    auto currentTime = MonotonicTime::now();
     327    auto estimatedNextDisplayRefreshTime = std::max(m_lastDisplayDidRefreshTime + frameDuration(), currentTime);
     328    auto timeoutTime = std::min(currentTime + maxAllowableRenderingUpdateDurationForSynchronization(), estimatedNextDisplayRefreshTime);
    328329
    329330    bool becameIdle = m_stateCondition.waitUntil(m_treeLock, timeoutTime, [&] {
     
    387388
    388389    Locker locker { m_treeLock };
     390   
     391    auto now = MonotonicTime::now();
     392    m_lastDisplayDidRefreshTime = now;
     393    serviceScrollAnimations();
    389394
    390395    if (m_state != SynchronizationState::Idle && canUpdateLayersOnScrollingThread())
  • branches/safari-612.4.2.1-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.h

    r286718 r286720  
    110110    bool m_receivedBeganEventFromMainThread WTF_GUARDED_BY_LOCK(m_treeLock) { false };
    111111    Condition m_waitingForBeganEventCondition;
     112   
     113    MonotonicTime m_lastDisplayDidRefreshTime;
    112114
    113115    // Dynamically allocated because it has to use the ScrollingThread's runloop.
Note: See TracChangeset for help on using the changeset viewer.