Bug 195388 - [macOS] Fixed elements can flicker on a page that is busy doing layout
Summary: [macOS] Fixed elements can flicker on a page that is busy doing layout
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Scrolling (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-06 16:57 PST by Simon Fraser (smfr)
Modified: 2019-03-08 08:47 PST (History)
3 users (show)

See Also:


Attachments
Testcase (18.59 KB, text/html)
2019-03-06 16:57 PST, Simon Fraser (smfr)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2019-03-06 16:57:54 PST
Created attachment 363817 [details]
Testcase

Fixed bars can flicker to incorrect positions on a page that is busy doing layout.
Comment 1 Simon Fraser (smfr) 2019-03-06 17:00:33 PST
Seen on macOS, reproduces in shipping Safari.

I think what's happening is that the main thread can be busy running JS etc, allowing a  commit on the main thread with a very stale position for the fixed layer. Meanwhile, the scrolling thread has moved ahead, and is continually pushing the layer to its correct position.

The fix is to allow the scrolling tree to have the final say on layer positions, so post-flush, traverse the scrolling tree on the main thread and have it set positions based on the scrolling thread's scroll position.
Comment 2 Simon Fraser (smfr) 2019-03-07 23:21:34 PST
Still not sure what's happening here. I have verified that the state of the layer tree as set by the scrolling thread is always correct (logging CALayer positions).

We may have a race between main thread commits setting layer positions, and the scrolling tree doing so. We don't really have any protection against CACommit racing.
Comment 3 Simon Fraser (smfr) 2019-03-08 08:47:02 PST
Does not reproduce with UI-side compositing and some applyScrollingTreeLayerPositions() work, so does seem to be caused by CACommit racing. I saw in traces that CACommits in main thread and scrolling thread are overlapping.