Read OffscreenCanvas snapshots on the canvas thread when constructing a VideoFrame from them
Categories
(Core :: Audio/Video: Web Codecs, task)
Tracking
()
| 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.
| Assignee | ||
Comment 1•4 days ago
|
||
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.
Description
•