godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.79k stars 21.13k forks source link

Some SVGs are not displayed since 4.3.beta3 #96491

Closed antimundo closed 1 month ago

antimundo commented 2 months ago

Tested versions

System information

Godot v4.3.stable - Windows 10.0.19045 - GLES3 (Compatibility) - AMD Radeon RX 6800 (Advanced Micro Devices, Inc.; 31.0.24033.1003) - Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz (4 Threads)

Issue description

I tried upgrading a project from Godot 4.2.2 to Godot 4.3, which I made using a lot of SVGs but all textures that used .svg doesn't show anymore in the game. No console errors, and the game runs fine, is just that the .svg textures are not been displayed.

If I open it with Godot 4.3 the .svg textures are not been displayed. Same with Godot 4.3.beta3 and later versions. imagen

If I open the project on Godot 4.2.2 it works just fine. Same with Godot 4.3.beta2 and previous versions. Captura de pantalla 2024-09-02 203305

I tested different Godot versions, and it seems to be reproducible in Godot 4.3.beta3 and later versions. But not reproducible (works fine) in Godot 4.3.beta2 and previous versions. (I'm always deleting the .godot folder after each test)

The version I open the project first is the key to reproduce the error

For some reason, if I delete the .godot folder, and then open and import the project with 4.3.beta2 (which works fine), and after that, I open it again with 4.3.stable everything seems to work fine. The same way, if I delete the .godot folder, and then open and import the project with 4.3.stable and then I go back to 4.3.beta2 the sprites don't appear.

Seems like it all depends on which version I open the project with first. If it's Godot 4.3.beta2 or earlier it works just fine, if it's Godot 4.3.beta3 or later the sprites don't appear.

Only with .svg files

Other files, like .png seems to work fine, this is happening just with .svg files to me.

Steps to reproduce

Clone or download this Godot Project "Poder Solar": https://github.com/antimundo/poder-solar Open it in Godot 4.3 See how most sprites are not been displayed.

Minimal reproduction project (MRP)

The project is open source and available at: https://github.com/antimundo/poder-solar

fire commented 2 months ago

Can you try using this https://www.thorvg.org/viewer to help us isolate if it's a Godot Engine bug or a Thorvg bug?

antimundo commented 2 months ago

Can you try using this https://www.thorvg.org/viewer to help us isolate if it's a Godot Engine bug or a Thorvg bug?

Seems like the SVGs are not showing there either... But they look perfectly normal if I open them with Firefox, Google Chrome, or Inkscape.

They even look look fine if I upload them here on GitHub:

power_plant

akien-mga commented 2 months ago

I can confirm the issue, which seems to have been introduced in ThorVG 0.13.8. I'll bisect and report it upstream.

As a side note, for some reason I can't open the MRP properly in 4.2.2-stable. That's pretty weird.

akien-mga commented 2 months ago

I reported the regression upstream: https://github.com/thorvg/thorvg/issues/2706

The root cause of the issue is that your SVG icons include text nodes which you're not actually using to display text. Removing them should fix your issue.

ThorVG (the library we use for SVG) should still handle them gracefully though and ignore the text node, but for now the latest version has a stricter interpretation of the spec.

akien-mga commented 2 months ago

The root cause of the issue is that your SVG icons include text nodes which you're not actually using to display text. Removing them should fix your issue.

To do this, you can optimize the SVGs with a tool like e.g. svgo, which will remove unused stuff from them (to reduce disk usage and clutter, but in this case it will also work around this bug).

npm install svgo
find -name "*.svg" -exec node_modules/.bin/svgo {} \;
rm -rf node_modules
antimundo commented 1 month ago

The root cause of the issue is that your SVG icons include text nodes which you're not actually using to display text. Removing them should fix your issue.

To do this, you can optimize the SVGs with a tool like e.g. svgo, which will remove unused stuff from them (to reduce disk usage and clutter, but in this case it will also work around this bug).

npm install svgo
find -name "*.svg" -exec node_modules/.bin/svgo {} \;
rm -rf node_modules

Indeed, removing that text node fixed the issue :)) thanks you so much for the advice! I hope this is fixed since it was very confusing that these SVGs were displayed on other apps but not Godot.

(By the way I don't understand why is there a text node on the SVGs, I don't remember adding any text to the SVGs on Inkscape (?))

capnm commented 1 month ago

(By the way I don't understand why is there a text node on the SVGs, I don't remember adding any text to the SVGs on Inkscape (?))

In Inscape, I usually keep the working copy (it includes a lot of internal configuration stuff; in your case, I guess empty \<text ... >\-tag lines) and save the intended result as a 'plain'-SVG copy.

I did a quick check with Godot v4.4.dev 835808e and TVG v0.14.9. It fixes all your files but still has issues if the text tag includes characters.

Files for further investigation: mrp-svg_text-tests-godot.zip

Fixed in https://github.com/thorvg/thorvg/pull/2716 CC @fire