Skip to content

Fix loadImage SVG file loading regression#8937

Merged
davepagurek merged 5 commits into
processing:mainfrom
gfrancine:main
Jun 22, 2026
Merged

Fix loadImage SVG file loading regression#8937
davepagurek merged 5 commits into
processing:mainfrom
gfrancine:main

Conversation

@gfrancine

@gfrancine gfrancine commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Resolves #8921

Changes:

  • Load images with HTMLImageElement instead of createImageBitmap.

    Reverts to the loadImage implementation in p5.js <v2.0 (pre- commit e43f709, which introduced the regression).

createImageBitmap cannot load vector images and will reject with an InvalidStateError.

Further reading:

PR Checklist

@gfrancine gfrancine force-pushed the main branch 3 times, most recently from e64954a to 660f9ab Compare June 18, 2026 13:09
@gfrancine gfrancine changed the title fix: handle SVGs in loadImage fix: handle vector images (SVGs) in loadImage Jun 18, 2026
@gfrancine gfrancine marked this pull request as ready for review June 18, 2026 13:42
@gfrancine gfrancine changed the title fix: handle vector images (SVGs) in loadImage fix: loadImage SVG file loading regression Jun 18, 2026
@gfrancine gfrancine changed the title fix: loadImage SVG file loading regression Fix loadImage SVG file loading regression Jun 18, 2026
@p5-bot

p5-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

@gfrancine gfrancine marked this pull request as draft June 19, 2026 04:37
@gfrancine gfrancine marked this pull request as ready for review June 19, 2026 05:06
@gfrancine

gfrancine commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Tiny important edit: the old implementation that loadImage was reverted to works by setting the Image src to the source path, which means the same image is loaded twice. Use the already-fetched image data instead (53b2068)

…map`

`createImageBitmap` throws when loading vector images -- revert to initial `loadImage` implementation pre- commit e43f709

See https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap
The pre-v2.0 implementation, which loadImage was reverted to, requests the same image twice. Use the fetched blob data instead
@ksen0

ksen0 commented Jun 22, 2026

Copy link
Copy Markdown
Member

Thank you for working on this!

[unit-tests (chrome)] test/unit/webgl/p5.Framebuffer.js > p5.Framebuffer > saveCanvas > should download a png file: test/unit/webgl/p5.Framebuffer.js#L681
AssertionError: expected "createElement" to be called with arguments: [ 'a' ]

Some tests are failing, could you take a look please?

@davepagurek

Copy link
Copy Markdown
Contributor

@ksen0 that's the flaky test @perminder-17 was mentioning recently. I'll rerun the tests, it looks like the others worked

@davepagurek davepagurek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the fix!

@davepagurek davepagurek merged commit 701306b into processing:main Jun 22, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[p5.js 2.0+ Bug Report]: loadImage cannot load SVG files

3 participants