REOPENED293284
In WebGPU when calling copyExternalImageToTexture, the results are different if called in the 'load' event vs after
https://bugs.webkit.org/show_bug.cgi?id=293284
Summary In WebGPU when calling copyExternalImageToTexture, the results are different ...
Gregg Tavares
Reported 2025-05-20 01:25:10 PDT
Created attachment 475317 [details] image via decode vs addEventListener In WebGPU these two snippets of code should load the same data ```js const img = new Image(); img.src = 'noise.png' await img.decode(); device.queue.copyExternalImageToTexture(...) ``` vs ```js const img = new Image(); img.src = 'noise.png' img.addEventListener('load', () => { device.queue.copyExternalImageToTexture(...) }); ``` They don't. Note, if you run the first one in first in the same page then the 2nd one will get the same results Repo attached
Attachments
image via decode vs addEventListener (5.58 KB, application/zip)
2025-05-20 01:25 PDT, Gregg Tavares
no flags
Mike Wyrzykowski
Comment 1 2025-05-20 07:22:28 PDT
Likely a bug in the external texture import path
Radar WebKit Bug Importer
Comment 2 2025-05-20 07:22:39 PDT
Mike Wyrzykowski
Comment 3 2025-05-20 08:24:34 PDT
I think this is above WebGPU in the general webkit image loading path, confirming
Mike Wyrzykowski
Comment 4 2025-05-20 08:32:58 PDT
CGImageGetAlphaInfo(...) is returning a different value in both cases. When the image is darker (matching Chrome), CGImageGetAlphaInfo(...) returns kCGImageAlphaPremultipliedFirst (0x2), /* For example, premultiplied ARGB */ When the image is brighter (problem case), CGImageGetAlphaInfo(...) returns kCGImageAlphaLast (0x3), /* For example, non-premultiplied RGBA */
Mike Wyrzykowski
Comment 5 2025-05-21 10:59:44 PDT
This is indeed at least partly a WebGPU issue, we are not handling when WebCore gives us back a premultiplied image (which appears to differ based on explicit call to decode). After the image is cached, we get back the same image. Though it also seems odd WebCore is giving us a premultiplied image in some cases when the source image in this repro is not premultiplied
Mike Wyrzykowski
Comment 6 2025-05-21 11:11:24 PDT
Change to match between the two versions and also match Chrome is quite simple, just checking the CTS to ensure zero regressions.
Mike Wyrzykowski
Comment 7 2025-05-21 17:51:49 PDT
EWS
Comment 8 2025-06-02 09:08:44 PDT
Committed 295690@main (b8888bb0a749): <https://commits.webkit.org/295690@main> Reviewed commits have been landed. Closing PR #45744 and removing active labels.
Mike Wyrzykowski
Comment 9 2025-07-02 18:52:48 PDT
Reopened Bugzilla. [WebGPU] bloooooom.vercel.app appears different in Safari/FireFox than Chrome, tracking revert in https://bugs.webkit.org/show_bug.cgi?id=295357.
Note You need to log in before you can comment on or make changes to this bug.