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

wasm: Wrong SVG size if the svg don't have explicit with/height #6715

Open
hunger opened this issue Nov 4, 2024 · 2 comments
Open

wasm: Wrong SVG size if the svg don't have explicit with/height #6715

hunger opened this issue Nov 4, 2024 · 2 comments
Labels
a:platform-wasm browser integration (mO,bT) bug Something isn't working
Milestone

Comments

@hunger
Copy link
Member

hunger commented Nov 4, 2024

The latch on the printerdemo looks wrong in Slintpad (1.8.0 version):

On chrome:

image

In Firefox:

image

Looks to me like the rendering of the SVG is missing/has the wrong size.

@ogoffart ogoffart added bug Something isn't working a:platform-wasm browser integration (mO,bT) labels Nov 4, 2024
@ogoffart ogoffart added this to the 1.9 milestone Nov 4, 2024
@ogoffart
Copy link
Member

ogoffart commented Nov 4, 2024

Note that this can be reproduced in slintpad, but not on the rust-compiled demo.

I believe the difference is that the rust demo uses resvg to render the SVG, while the interpreter uses a <img> tag with a source being the URL of the .svg

@ogoffart ogoffart changed the title Printerdemo: "Latch" on the left side behind the sidebar icons looks wrong wasm: Wrong SVG size if the svg don't have explicit with/height Nov 8, 2024
@ogoffart
Copy link
Member

ogoffart commented Nov 8, 2024

The home-automation's padlock icon has the same issue.
The problem appear in the printer demo since commit 0fd9bf4 changed the svg so that it doesn't have a width and height hardcoded in the svg element.

resvg which is what we use to render svg in non-web, uses the size of the viewBox when width and height are not specified.

On the wasm interpreter, we do use an <img> element's naturalWidth / naturalHeight.

self.dom_element.natural_width(),

That returns 0 on firefox, and some wrong value with chromium.
I wonder if there is a better way to get the size that uses the viewbox of the svg if width and height are not specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:platform-wasm browser integration (mO,bT) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants