Bug 250653

Summary: Scrolling can stutter when the main thread is causing jank
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: ScrollingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bramus, rik, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://codepen.io/bramus/pen/LYBLeYv
Attachments:
Description Flags
Test none

Description Simon Fraser (smfr) 2023-01-15 12:26:51 PST
Even though we have off-main-thread scrolling, some kinds of main thread jank still cause scroll stutters.

See https://twitter.com/bramus/status/1614606416932741121
Comment 1 Radar WebKit Bug Importer 2023-01-15 12:27:10 PST
<rdar://problem/104280648>
Comment 2 Simon Fraser (smfr) 2023-01-15 12:28:03 PST
Created attachment 464509 [details]
Test
Comment 3 Simon Fraser (smfr) 2023-01-15 12:39:23 PST
We get into a state where ThreadedScrollingTree::m_state is Idle, but the main thread is blocked. Noting is triggering the m_delayedRenderingUpdateDetectionTimer in this case.
Comment 4 Simon Fraser (smfr) 2023-01-15 12:52:50 PST
The interesting thing about this test case is that the jank is pure JS; nothing is touching the DOM, so nothing triggers `ThreadedScrollingTree::didScheduleRenderingUpdate` which sets some state that allows the scrolling thread to take over scrolling.
Comment 5 Simon Fraser (smfr) 2023-01-15 12:56:20 PST
Specifically, m_renderingUpdateWasScheduled is false in ThreadedScrollingTree::displayDidRefreshOnScrollingThread() so we don't trigger the unresponsive main thread detection.