Open Bug 1940072 Opened 1 month ago Updated 5 hours ago

OffscreenCanvas.transferFromImageBitmap() and other canvas-reading broken with WebGPU

Categories

(Core :: Graphics: WebGPU, defect)

Firefox 135
defect

Tracking

()

ASSIGNED

People

(Reporter: huscar, Assigned: sotaro)

References

(Depends on 1 open bug)

Details

Steps to reproduce:

Tried to use OffscreenCanvas.transferFromImageBitmap() to transfer a bitmap of WebGPU output to another canvas. Was unsure about whether this was me or Firefox, so I went looking for conformance tests, Firefox appears to be failing them: https://gpuweb.github.io/cts/standalone/?q=webgpu:web_platform,canvas,readbackFromWebGPUCanvas:*

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core
Component: Graphics: Canvas2D → Graphics: WebGPU
Severity: -- → S3

Looked into the following one test failure. (Test is for onscreenCanvas)

In the test, snapshot seemed to get invalid data(just zero).

initWebGPUCanvasContent() function in https://gpuweb.github.io/cts/out/webgpu/web_platform/canvas/readbackFromWebGPUCanvas.spec.js submit the test data to current texture. But the current texture was not presented to screen.

WebGPUParent::GetFrontBufferSnapshot() implementation has a problem. The GetFrontBufferSnapshot() expects that the texture is already presented by WebGPUParent::RecvSwapChainPresent(). The GetFrontBufferSnapshot() does not handle a case that the texture is not yet presented by the RecvSwapChainPresent().

Depends on: 1940374
Assignee: nobody → egubler
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

:sotaro: I'm still getting just zero for the snapshots in that test you've linked on my Windows 11 machine. What platform were you testing from?

Flags: needinfo?(sotaro.ikeda.g)
Depends on: 1945708

When pref dom.webgpu.allow-present-without-readback = false, the readback worked on Windows. When ExternalExture was still being used by wgpu, ExternalTexture::GetSnapshot() did not work as expected.

Conformed bug 1945708 fix addressed the problem.

Flags: needinfo?(sotaro.ikeda.g)

Sotaro, does that mean that this bug can be closed?

Flags: needinfo?(sotaro.ikeda.g)

Sorry, comment 5 was not clear. This bug is not addressed.

bug 1945708 fix changed the test result like the following.


From

actual == 0x: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
failed -> xx xx xx xx xx xx xx xx xx
expected == 00 66 ff 00 66 00 ff 66 00 00 ff 66 66 00 ff

To

actual == 0x: 00 ff 66 00 ff 00 66 ff 00 00 66 ff ff 00 66
failed -> xx xx xx xx xx xx xx xx xx
expected == 00 66 ff 00 66 00 ff 66 00 00 ff 66 66 00 ff

Flags: needinfo?(sotaro.ikeda.g)

Hmm, this might have some platform-specific pieces.

On my M1 MacBook Pro, I'm still getting zero-data failures for, e.g., webgpu:web_platform,canvas,readbackFromWebGPUCanvas:onscreenCanvas,uploadToWebGL:format="bgra8unorm";alphaMode="opaque";webgl="webgl";upload="texImage2D":

EXPECTATION FAILED: Array had unexpected contents at indices 2 through 15.
 Starting at index 1:
   actual == 0x: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   failed ->        xx xx    xx    xx xx       xx xx xx    xx
 expected ==     00 66 ff 00 66 00 ff 66 00 00 ff 66 66 00 ff
ErrorWithExtra@https://gpuweb.github.io/cts/out/common/util/util.js:23:5
failCheckElements@https://gpuweb.github.io/cts/out/webgpu/util/check_contents.js:265:10
checkElementsEqual@https://gpuweb.github.io/cts/out/webgpu/util/check_contents.js:66:10
@https://gpuweb.github.io/cts/out/webgpu/web_platform/canvas/readbackFromWebGPUCanvas.spec.js:427:14

I'm also seeing an error I've never seen before for webgpu:web_platform,canvas,readbackFromWebGPUCanvas:onscreenCanvas,snapshot:format="rgba8unorm";alphaMode="premultiplied";colorSpace="srgb";snapshotType="toDataURL" and similar tests:

EXCEPTION: EncodingError: Invalid encoded image data.
Assignee: egubler → sotaro.ikeda.g

The test of comment 7 was done on Windows.

Depends on: 1948175
Depends on: 1948215
You need to log in before you can comment on or make changes to this bug.