structuredClone throws DomException when called with ImageBitmap derived from OffscreenCanvas
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
People
(Reporter: william.archinal, Unassigned)
References
Details
Steps to reproduce:
- Enable OffscreenCanvas (gfx.offscreencanvas.enabled = true)
- Run this JS code:
const ctx = new OffscreenCanvas(width, height).getContext('2d');
await renderSomeContentOntoCanvas(ctx); // pseudocode, in our application this renders a JPEG onto the canvas
spritesheet = await createImageBitmap(ctx.canvas); // Returns ImageBitmap
structuredClone(spritesheet);
Actual results:
The final line throws:
DOMException: The object could not be cloned.
Expected results:
This should not have thrown an error.
Notably, if we use a HTMLCanvasElement instead of an OffscreenCanvas, the JS code works as expected.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Canvas: 2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 2•3 years ago
|
||
I made a basic test case based on the example, but I think we need a bit more to go on. It can fail to clone for a bunch of reasons, mostly edge cases such as OOM, but the most likely are:
- The bitmap is marked as write only
- The bitmap is closed
It would be nice if we raised a better exception so that there is something more actionable for content authors.
Comment 3•3 years ago
|
||
I wrote a patch in bug 1777411 which should improve the error messages so that we can get a better idea of why the clone failed.
Comment 4•3 years ago
|
||
Can you retry on the latest nightly? The error message should be more useful for figuring out what happened.
Reporter | ||
Comment 5•3 years ago
|
||
I'm still getting the same unspecific error message: "DataCloneError: The object could not be cloned."
This is on Firefox Nightly Version 104.0a1 (2022-07-03)
Comment 6•3 years ago
|
||
Okay so it seems like it doesn't have anything to do with ImageBitmap then. We need a reduced test case to be actionable here.
Description
•