Closed Bug 2093540 Opened 4 days ago Closed 3 days ago

Read OffscreenCanvas snapshots on the canvas thread when constructing a VideoFrame from them

Categories

(Core :: Audio/Video: Web Codecs, task)

task

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 VideoFrame constructor that takes an OffscreenCanvas wraps the canvas snapshot in a SourceSurfaceImage without reading it back. The pixels are only read later, when a consumer such as VideoEncoder converts the frame on its own task queue.

That works for the software snapshots that OffscreenCanvas produces today. Once OffscreenCanvas 2D can use accelerated canvas, including on DOM workers, its snapshot is a canvas recording surface that can only be read back on the thread that owns the canvas. Reading it on the encoder task queue would then fail.

The HTMLCanvasElement constructor already avoids this by passing the snapshot through CreateImageFromSourceSurface, which reads it into a BGRA data surface right away. The OffscreenCanvas constructor should do the same. This adds a readback when the frame is constructed rather than when it is used, which matches the HTMLCanvasElement path.

This has to land before accelerated OffscreenCanvas is enabled.

An accelerated canvas snapshot can only be read back on the canvas' owning
thread, so read it now as is done for HTMLCanvasElement, rather than when the
encoder converts it on its own task queue.

Pushed by aosmond@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/207a3dae4129 https://hg.mozilla.org/integration/autoland/rev/7c2609761f3b Read OffscreenCanvas snapshots when creating a VideoFrame from them. r=media-playback-reviewers,alwu
Status: ASSIGNED → RESOLVED
Closed: 3 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: