ShukantPal / pixi-essentials

The best goodies for performant, enterprise-level applications built on PixiJS
https://api.pixijs.io
MIT License
275 stars 36 forks source link

[SVG] Loading svg in Firefox #100

Closed ThomasvanHoutum closed 8 months ago

ThomasvanHoutum commented 8 months ago

When I try to load an svg with the @pixi-essentials/svg package like this:

this._svgPlan = await SVGScene.from(svgPath);
this.pixiViewport.addChild(this._svgPlan);

It works fine for chrome and safari, but for Firefox I get this error: TypeError: e.viewBox.baseVal is null I am certain the svgPath has not changed in between browsers, so I am not quite sure what the issue is here.

ThomasvanHoutum commented 8 months ago

This seems to be an issue with the way the browsers interpreted a missing viewBox, the svg I was using did not have one. Chrome will return the value 0 when this is the case, while Firefox will return null. This will give the error mentioned when instantiating an SVGScene.

To fix this simply setting the viewBox will do, even if it's set to 0 0 0 0.