Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox drawImage() fails with an SVG image without width and height #29

Closed
GoodBoyNinja opened this issue Aug 1, 2023 · 2 comments
Closed

Comments

@GoodBoyNinja
Copy link

In my project:

import image from "../assets/images/image.svg";
let options = {
	...
	shape: "image",
	imageUrl: image,
};

Particles are rendering great on safari and chrome, but on firefox the console is getting filled with these errors:
DOMException: CanvasRenderingContext2D.drawImage: Passed-in canvas is empty

drawimageerr@2x

After some debugging, my best guess is that it's related to this Firefox bug:
drawImage() fails silently when drawing an SVG image without @width or @height

My image.svg indeed does not have a width and a height set, which causes the particle canvas to have a size of 0 and fail to render.

If this can't be fixed it might be worth mentioning it on the readme or displaying a dedicated error in the console when the project is not in production.

Thanks for this project, it's easy to get up and running!

@simeydotme
Copy link
Owner

Ah yes, thanks for re-surfacing this!
I also found this error ages ago, #2 issue but after reading the same bugzilla I ignored it as I assumed it would be fixed at the browser level at some point ... I guess I was wrong :/ ... what's funny though, is it looks like someone has written a fix for it 1 month ago, hah!

Let me pin this issue!

@simeydotme simeydotme pinned this issue Aug 1, 2023
@simeydotme
Copy link
Owner

As I did in #2 resolution, the best way to avoid this right now, is to use a svg file hosted somewhere with a width/height attribute, or us a data-uri with the width/height assigned.

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

No branches or pull requests

2 participants