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

"get a copy of the image contents of a context" does not handle case where canvas is unconfigured #4606

Open
1 task
kainino0x opened this issue Apr 25, 2024 · 2 comments
Labels
api resolved Resolved - waiting for a change to the API specification api WebGPU API
Milestone

Comments

@kainino0x
Copy link
Contributor

kainino0x commented Apr 25, 2024

In get a copy of the image contents of a context, we have this line:

  1. Let alphaMode be context.[[configuration]].alphaMode.

This assumes there is a configuration. If the canvas is unconfigured (has never been configured or has been unconfigure()d), we need to specify what should happen. Almost certainly it should return a transparent image (which makes the canvas invisible, but also makes it provide a transparent image when used as an image source), though our default alphaMode is "opaque" so it could also go the other way.

@kainino0x kainino0x added the needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet label Apr 25, 2024
@kainino0x kainino0x added api WebGPU API and removed needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet labels Apr 25, 2024
@kainino0x
Copy link
Contributor Author

kainino0x commented May 20, 2024

As promised in the meeting I've looked into the behavior of a canvas with no context. In all browsers it seems to behave exactly the same as a blank 2d canvas with alpha: true: https://codepen.io/kainino0x/pen/PovNWbB
i.e. it returns a blank image of the size of the canvas.
(Tested on Mac with Chrome Canary, Firefox Nightly, and Safari Technology Preview.)

So indeed, it looks like that's what we should do for unconfigured "webgpu" canvases as well, per the meeting consensus. (Incidentally, Chrome and Safari have similar behavior for canvases that do have "2d" contexts but have not been drawn to yet, which you can see if you look at the behavior copying from an alpha: false canvas - it returns a transparent image despite alpha: false. Firefox does what you'd more likely expect and gives you opaque black.)

@kainino0x kainino0x added the api resolved Resolved - waiting for a change to the API specification label May 20, 2024
@kainino0x kainino0x added this to the Milestone 1 milestone May 20, 2024
@Kangz
Copy link
Contributor

Kangz commented May 21, 2024

GPU Web WG 2024-05-15
  • KN: This is just a corner case. We have a “null pointer exception” in the spec text, in effect. When we try to get the picture out of the canvas, we haven’t defined what happens when the canvas hasn’t been configured at all. So we don’t know what should happen. Blank image? Transparent image? We know the size, because that’s associated with the canvas. I think it should probably be a blank transparent image, which is equivalent to nothing at all when composited
  • KG: It would be nice if there were not a new intermediate state for this, and do whatever the canvas would have done if you hadn’t gotten a context from it.
  • KN: Good point. That’s almost certainly a blank transparent image the size of the canvas, but I can work out the details.
  • (General consensus to make it behave like a canvas that hasn’t had a context attached yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api resolved Resolved - waiting for a change to the API specification api WebGPU API
Projects
None yet
Development

No branches or pull requests

2 participants