Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readbackFromWebGPUCanvas:transferToImageBitmap_unconfigured_nonzero_size expects opaque black image (alpha == 255) #4259

Open
jamienicol opened this issue Mar 6, 2025 · 0 comments

Comments

@jamienicol
Copy link

jamienicol commented Mar 6, 2025

I'm looking at making the above test pass in Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1948580)

I can see the test expects the returned bitmaps pixels to have an alpha value of 255. But looking at the spec (steps 1 to 3) it seems to me the returned image should be transparent black, ie alpha == 0, as the canvas is unconfigured.

Does the CTS need updated, or am I misreading the spec?

jamienicol added a commit to jamienicol/gecko that referenced this issue Mar 20, 2025
…red webgpu canvas. r?#webgpu-reviewers

The spec[1] (steps 1-3) mandates we return a transparent black image
of the same size as the canvas when attempting to snapshot an
unconfigured webgpu canvas context.

Currently, CanvasContext::GetSurfaceSnapshot() returns null in such
cases. nsLayoutUtils::SurfaceFromOffscreenCanvas() then handles this
by returning a transparent black surface. This should be sufficient.
However, the relevant CTS tests[2] currently expect an *opaque* black
image to be returned. An issue[3] has been filed upstream.

This patch makes us match the CTS' expected behaviour, by specifically
handling the unconfigured case in CanvasContext::GetSurfaceSnapshot(),
and returning an opaque black surface of the required size. We clear
the pixels using libyuv::ARGBRect() for performance reasons, like we
do in BufferTexture.cpp when initializing BufferTextureData buffers.

If and when the CTS is updated to expect a transparent black surface,
we can either revert this patch in its entirety, or simply pass the
correct value for aIsOpaque to MakeFallbackImage().

[1] https://www.w3.org/TR/webgpu/#abstract-opdef-get-a-copy-of-the-image-contents-of-a-context
[2] webgpu:web_platform,canvas,readbackFromWebGPUCanvas:transferToImageBitmap_unconfigured_nonzero_size:*
[3] gpuweb/cts#4259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant