Closed Bug 2093133 Opened 4 days ago Closed 4 days ago

Reftest screenshots can miss frames presented over ImageBridge, such as OffscreenCanvas frames

Categories

(Core :: Graphics, defect)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

The reftest and WPT reftest harnesses call nsIDOMWindowUtils.updateLayerTree() in the content process before the parent takes the screenshot with drawWindow(..., DRAWWINDOW_USE_WIDGET_LAYERS). updateLayerTree paints and waits for the layer transaction to be processed, but frames presented over ImageBridge are not part of that transaction:

  • an OffscreenCanvas frame, from a DOM worker or from the main thread, is handed to the content process ImageBridge thread by ImageBridgeChild::UpdateCompositable and sent on the PImageBridge channel;
  • video frames go through the same path (VideoFrameContainer uses an asynchronous ImageContainer).

If the ImageBridge thread has not sent the update yet when the harness flushes, the screenshot is taken without the frame and the canvas or video is missing.

This shows up as intermittent failures of WPT reftests that draw to a transferControlToOffscreen() canvas right before finishing, for example /html/canvas/offscreen/manual/text/canvas.2d.offscreen.transferred.lang.html and its inherit variants on Android, where the emulator is slow enough for the ImageBridge thread to fall behind. Adding a 300 ms delay before the ImageBridge send in ImageBridgeChild::UpdateCompositable reproduces it every time on an Android emulator: the canvases are missing (maximum difference 255).

Proposed fix: call ImageBridgeChild::WaitFlushTasks() in nsDOMWindowUtils::UpdateLayerTree before painting. The ImageBridge updates are then sent before the layer transaction that updateLayerTree waits on. With that change and the same delay, the canvases are drawn. It adds no IPC and only affects callers of updateLayerTree, which are test harnesses.

It does not close every gap: the ImageBridge update and the layer transaction travel on different channels, so the compositor could in principle still handle them out of order, and an OffscreenCanvas commit that has not run yet on the main thread is not flushed.

Frames presented through ImageBridge, such as those of an OffscreenCanvas or a
video, are not part of the layer transaction, so a compositor snapshot taken
after updateLayerTree could miss them.

Pushed by aosmond@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/dd6386ed022e https://hg.mozilla.org/integration/autoland/rev/e6d245159cb8 Flush pending ImageBridge updates in nsDOMWindowUtils::UpdateLayerTree. r=gfx-reviewers,lsalzman
Status: ASSIGNED → RESOLVED
Closed: 4 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: