Closed Bug 1457470 Opened 3 years ago Closed 3 years ago

Avoid race condition where we sample APZ transforms concurrently with updating the hit-testing tree

Categories

(Core :: Graphics: WebRender, enhancement, P1)

Other Branch
enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: kats, Assigned: kats)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [gfx-noted])

With the patch from bug 1457466 I discovered a small race condition that makes the scrollbar jittery while scrolling around on http://tests.themasta.com/gibberish.txt

The problem is at [1] we run the post-swap hook concurrently with the sampler hook at [2], and this can produce unexpected results. Consider the scenario where we have an inflight scene build happening on the scene builder thread, and the built scene is sent over to the render backend thread. The RB thread also gets a GenerateFrame transaction in its queue following the built scene transaction. The scene swap happens on the RB thread, and then the RB thread continues processing its queue and does the sampling for the GenerateFrame transaction. Meanwhile, the scene builder thread got unblocked and is running the post-swap hook. If the sampling happens before the post-swap hook is done, the sampled values will be relative to the old scene, because it's the post-swap hook that updates the APZ's last-content-paint information. We need to ensure that the GenerateFrame doesn't sample until after the post-swap hook is done and APZ has the new scene information installed.

[1] https://searchfox.org/mozilla-central/rev/78dbe34925f04975f16cb9a5d4938be714d41897/gfx/webrender/src/scene_builder.rs#167-171
[2] https://searchfox.org/mozilla-central/rev/78dbe34925f04975f16cb9a5d4938be714d41897/gfx/webrender/src/render_backend.rs#968
Fixed via github PR which got merged into gecko.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.