Skip to content

Add more copyExternalImageToTexture tests as Chrome/Safari/Firefox are failing to agree how to load an image #4545

Open

Description

@greggman

this example: https://jsgist.org/?src=e9261816382d2637f29e8e7f105c1c40

gets

  • Top-left RGBA: 255 255 255 1 on Firefox
  • Top-left RGBA: 255 0 0 1 on Safari
  • Top-left RGBA: 130 101 73 1 on Chrome

I think Chrome is correct (130, 101, 73, 1) is what's in the file.

This issue might be from createBitmapImage?

Activity

  1. greggman commented on Dec 23, 2025

    @greggman
    MemberAuthor

    Trying with Image instead of createImageBitmap

    https://jsgist.org/?src=2359aec968f72ec4b24f69c712753d59

    • Chrome: Top-left RGBA: 130 101 73 1
    • Safari: Top-left RGBA: 1 0 0 1
    • Firefox: Top-left RGBA: 130 101 73 1
  2. kainino0x commented on Jan 2, 2026

    @kainino0x
    Collaborator

    PNG is unpremultiplied, so if you copyExternalImageToTexture without premultipliedAlpha: true and copy that directly into the canvas you'll end up with undefined results on the display. That is not allowed to affect the readback result, but it does affect how it appears on screen.

    Here are my notes from playing with this sample on Mac:

    • ImageMagick seems to confirm 130 101 73 1 (magick FurBaseColorAlpha.png -format '%[fx:255*u.p{0,0}.r] %[fx:255*u.p{0,0}.g] %[fx:255*u.p{0,0}.b] %[fx:255*u.p{0,0}.a]' info:) - noting it's not fully transparent so there shouldn't be any issues with transparent pixels having arbitrary color values.
    • Firefox is initially missing their texture-to-canvas-conversion step - probably specific to filling a canvas using copyTextureToTexture - causing the BGRA-RGBA conversion step and alphaMode: 'opaque' not to apply. It fixes after switching away from the tab for a few seconds and back.
    • EDIT: continued in next post
  3. kainino0x commented on Jan 2, 2026

    @kainino0x
    Collaborator

    Oops, posted before I was done.

    • In all browsers I think the createImageBitmap colorSpaceConversion option is behaving correctly. It should have no effect because the image is already sRGB.
    • In Safari and Firefox, I think the createImageBitmap premultiplyAlpha option is behaving incorrectly. It always behaves like premultiplyAlpha: 'premultiply' which results in the R/G/B values getting "quantized" into the range of A (so either 0 or 1). Safari quantizes to 1,0,0, and Firefox quantizes to 1,1,1. Then they unpremultiply to 255,0,0 and 255,255,255, respectively.
    • In Safari something is going badly wrong with the Image path, I'm not sure what, but the color is very wrong (regardless of -srgb). At pixel 100,100, I'm getting RGBA 128,99,99,252 instead of the correct 130,100,71,252. Also, it doesn't do the red-blue flip when doing copyExternalImageToTexture into BGRA. No such issues in the ImageBitmap path.
  4. kainino0x commented on Jan 2, 2026

    @kainino0x
    Collaborator

    We do have tests that are supposed to test some of these things, but I don't think we try very hard to test createImageBitmap itself. In particular, we don't have Blob-to-ImageBitmap or Image-to-ImageBitmap cases.
    https://github.com/gpuweb/cts/tree/main/src/webgpu/web_platform/copyToTexture

    It would be useful to see if createImageBitmap is broken even for WebGL.

  5. kainino0x commented on Jan 2, 2026

    @kainino0x
    Collaborator

    https://gpuweb.github.io/cts/standalone/?q=webgpu:web_platform,copyToTexture,image:* does not pass in Safari at all - every test case fails. It passes in Chrome and Firefox (except for new formats Firefox doesn't implement yet).

  6. greggman commented on Jan 5, 2026

    @greggman
    MemberAuthor

    I think the thing not being tested that's failing on firefox, there is no webgpu:web_platform,copyToTexture,ImageBitmap:from_ImageData:from_Image there is only from_ImageData, from_canvas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions