Open Bug 2003863 Opened 17 hours ago Updated 1 hour ago

createImageBitmap gives unhelpful/incorrect error messages

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 147
defect

Tracking

()

Tracking Status
firefox147 --- affected

People

(Reporter: jakea, Unassigned)

Details

createImageBitmap(new Blob(['YO']));
  • Firefox: DOMException: An attempt was made to use an object that is not, or is no longer, usable
  • Chrome: InvalidStateError: The source image could not be decoded.
  • Safari: InvalidStateError: Cannot decode the data in the argument to createImageBitmap

Firefox's error seems unhelpful/incorrect.

Is there other cases where it gives unhelpful error messages that you encountered that seem distinct from this? If there is more, might be good to list them.

Here's a test https://random-stuff.jakearchibald.com/bug-repros/createimagebitmap-errors/ (see the console) - it's not completely exhaustive, but pretty detailed.

  • "Invalid SVG <img>" should error with something like "The SVG image is invalid"
  • "Zero width SVG blob" should error with something like "The SVG image must have nozero width"
  • "Zero height SVG blob" should error with something like "The SVG image must have nozero height"
  • "Zero width and height SVG blob" should error with either of the above, or both
  • "Image hasn't loaded yet" should error with "Image is not completely available"
  • "<canvas> with zero width" should error with something like "The <canvas> must have a nonzero width"
  • "<canvas> with zero height" should error with something like "The <canvas> must have a nonzero height"
  • As one of the above for the width + height 0 case, or both
  • "Detached ImageBitmap" should error with something like "The ImageBitmap is detached (closed/transferred)"
  • "SVG blob without natural dimensions and no resizeWidth/resizeHeight" should error with something like "The SVG image lacks natural dimensions"
  • "Invalid image data" should error with something like "The image could not be decoded"
You need to log in before you can comment on or make changes to this bug.