Bug 234328

Summary: Twitter scroll stutter: ensure that CA backing store is always deallocated on the main thread
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: ScrollingAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarcelo, ews-watchlist, fred.wang, jamesr, luiz, simon.fraser, thorton, tonikitoo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
thorton: review+, ews-feeder: commit-queue-
Patch ews-feeder: commit-queue-

Description Simon Fraser (smfr) 2021-12-14 17:54:18 PST
Twitter scroll stutter: ensure that CA backing store is always deallocated on the main thread
Comment 1 Simon Fraser (smfr) 2021-12-14 17:59:45 PST
Created attachment 447186 [details]
Patch
Comment 2 Simon Fraser (smfr) 2021-12-14 17:59:49 PST
<rdar://problem/85892959>
Comment 3 Tim Horton 2021-12-14 19:45:00 PST
Comment on attachment 447186 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=447186&action=review

Not the least frightening patch I've ever seen.

> Source/WebCore/WebCore.xcodeproj/project.pbxproj:-33104
> -				7B582DD82716F55B004B92D0 /* (null) in Headers */,

This seems bad

> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.mm:82
> +            RunLoop::main().dispatch([] {

Isn't it the scrolling thread runloop you're racing here (freeing the transaction), not the main thread?
Comment 4 Simon Fraser (smfr) 2021-12-14 20:09:44 PST
Comment on attachment 447186 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=447186&action=review

>> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.mm:82
>> +            RunLoop::main().dispatch([] {
> 
> Isn't it the scrolling thread runloop you're racing here (freeing the transaction), not the main thread?

Probably, but we know we've exited the scrolling thread transaction (tho it may still be in the teardown phase), and we have a dispatch here so it should almost always win. I never saw us lose the race in practice. If we do, it's not the end of the world.
Comment 5 Simon Fraser (smfr) 2021-12-14 21:20:00 PST
Created attachment 447201 [details]
Patch
Comment 6 EWS 2021-12-15 09:47:18 PST
Committed r287079 (?): <https://commits.webkit.org/r287079>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447201 [details].