Canvas updated by offscreen canvas, can not be used as image source for another canvas
Categories
(Core :: Graphics: CanvasWebGL, defect, P3)
Tracking
()
People
(Reporter: derijcke.erik, Assigned: aosmond)
References
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Steps to reproduce:
- Create canvas (1)
- Transfer control to offscreen canvas
- Use webgl in worker using offscreen canvas to update canvas (1)
- Create another canvas (2)
- Use canvas (1) to draw into canvas (2) using context 2d.
test program: https://jsfiddle.net/pm46knoc/
Actual results:
- Canvas (2) remains white
- Firefox tab frequently hard crashes
Expected results:
- Canvas (2) should have identical contents of canvas (1)
Updated•6 years ago
|
Comment 1•6 years ago
|
||
You also need to enabled the pref gfx.offscreencanvas.enabled to reproduce this.
Updated•6 years ago
|
| Reporter | ||
Comment 2•6 years ago
|
||
(In reply to Timothy Nikkel (:tnikkel) from comment #1)
You also need to enabled the pref gfx.offscreencanvas.enabled to reproduce this.
If you can confirm this, does this mean the status can be set to CONFIRMED?
Comment 3•5 years ago
|
||
Crashes tab at Nightly 72.0a1 (32-bit). Displays images then crashes tab at Firefox 70.0.1.
Related https://plnkr.co/edit/BU69GGcVUb8RULpsSmn3?p=preview
Comment 4•5 years ago
|
||
Does not display image source at otherCanvas.
Comment 5•5 years ago
|
||
A workaround for Firefox 70.0.1. Crashes tab at Nightly 72.0a1.
Substitute executing drawImage() with ImageBitmap of canvas within Worker onmessage handler for checkSize to avoid NS_ERROR_FAILURE
worker.onmessage = async _ => otherCtx.drawImage(await createImageBitmap(await (await fetch(canvas.toDataURL())).blob()), 0, 0)
within render after gl.commit(), self.postMessage(null) https://plnkr.co/edit/i8nSBaAKNwXsKSEIevJ5?p=preview
Comment 6•5 years ago
|
||
Reproduced
- Canvas (2) remains white
- Firefox tab frequently hard crashes
at Firefox 70.0.1 and Nightly 72.0a1 (32-bit) *nix.
Chromium 80 outputs
- Canvas (2) should have identical contents of canvas (1)
| Assignee | ||
Comment 7•3 years ago
|
||
In Chrome, I can see this works. The part we are missing is being able to use in DrawImage (and CreateImageBitmap) an HTMLCanvasElement that has TransferControlToOffscreen called on it. It calls HTMLCanvasElement::GetSurfaceSnapshot which only returns something if it owns the context:
This shouldn't be that hard to pull the snapshot out via OffscreenCanvas::GetSurfaceSnapshot.
| Assignee | ||
Comment 8•3 years ago
|
||
There are wpt tests for this, but they only run on canvas 2d, not WebGL.
| Assignee | ||
Comment 9•3 years ago
|
||
When CanvasRenderingContext2d.drawImage, or createImageBitmap are
called with an HTMLCanvasElement with an OffscreenCanvas gotten through
transferControlToOffscreen, we do not snapshot the underlying
OffscreenCanvas. This patch makes it so we do.
There are WPT tests for this, but they only run for canvas 2d.
| Assignee | ||
Updated•3 years ago
|
Comment 10•3 years ago
|
||
Comment 11•3 years ago
|
||
| bugherder | ||
Updated•3 years ago
|
Comment 12•3 years ago
|
||
I managed to reproduce the issue on Nightly from 2021-02-04 on macOS 10.15 by using the test program from comment 0.
I verified the fix using latest Nightly 98.0a1 and Firefox 97.0 on macOS 10.15, Ubuntu 18.04 x64 and Windows 10 x64. The issue is not reproducing anymore.
Description
•