Open Bug 1948583 Opened 6 months ago Updated 5 days ago

ImageData does not support color space

Categories

(Core :: Graphics: Color Management, defect)

defect

Tracking

()

People

(Reporter: sotaro, Unassigned, NeedInfo)

References

(Depends on 2 open bugs, Blocks 3 open bugs)

Details

During running test in Bug 1940072, the following code caused exception.

const srcImgData = new ImageData(2, 2, { colorSpace: srcColorSpace });

convertRGBA8UnormBytesToColorSpace - readbackFromWebGPUCanvas.spec.ts:83:21
TypeError: ImageData constructor: Argument 1 is not an object.

ImageData.webidl does not have color space.

https://html.spec.whatwg.org/multipage/canvas.html#imagedata

Blocks: 1940072

This was added in https://github.com/whatwg/html/pull/6562 (which points to bug 1703654 as our implementation bug, but that was only used to implement support in the WebGL canvas).

Severity: -- → S3

This is more gfx issue, I think. Sure, there is some minor webidl bindings changes needed too.

Severity: S3 → --
Component: DOM: Core & HTML → Graphics
Blocks: HDR
Severity: -- → S3

Simply adding the field to the ImageData webidl does in fact "fix" the tests, but is certainly not what we want to do. (I assume the tests end up working by accident because neither webgpu nor canvas2d handle colorspaces correctly.)

Kelsey, do you know what work would be involved to support this? The test appears to call Canvas2D.drawImage where the canvas has a different colorspace than the webgpu context. It then does the conversion by hand by creating an ImageData with one colorspace and a canvas2d with another, and calling putImageData() then getImageData(). Then it compares the resulting pixel values of these two operations to ensure they match.

I'm not sure I understand how this is testing webgpu functionality as opposed to canvas 2d. Ideally the CTS would have variants of these tests that avoid doing these conversions, allowing us to still test the readback functionality despite not supporting these APIs.

Flags: needinfo?(jgilbert)
Component: Graphics → Graphics: Color Management
Flags: needinfo?(jgilbert) → needinfo?(ahale)
Blocks: 1972744
Flags: needinfo?(ahale)

I need to take a look at https://developer.mozilla.org/en-US/docs/Web/API/ImageData/colorSpace and the spec to see how this fits into the HDR Canvas story.

Flags: needinfo?(ahale)
Depends on: 1963359
Depends on: 1942956
You need to log in before you can comment on or make changes to this bug.