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

Specific SVG file with bundled PNG image fails to be imported #68822

Closed
metanoder opened this issue Nov 18, 2022 · 11 comments · Fixed by #69048
Closed

Specific SVG file with bundled PNG image fails to be imported #68822

metanoder opened this issue Nov 18, 2022 · 11 comments · Fixed by #69048

Comments

@metanoder
Copy link

metanoder commented Nov 18, 2022

Godot version

4.0 Beta 5

System information

M1 MacBook Pro Arm 32gb

Issue description

Single SVG file crashes Godot

I have a game on Godot 3.5 and use the plug in dialogic 2.0 for my dialog.
Single SVG file crashes Godot. Size of SVG is tiny. Under 1mb (854 kb).

Steps to reproduce

introduce and upload single svg file to file system.

Game Engine Crashes...

Minimal reproduction project

In comment below...

@Calinou
Copy link
Member

Calinou commented Nov 18, 2022

@metanoder Please upload a minimal reproduction project to make this easier to troubleshoot.

How large are the images in total? Which format are they using? What's their size in pixels on average? Any images that are really small or really large?

To get an accurate crash backtrace, consider compiling a debug build then running the editor from a terminal until it crashes.

@metanoder metanoder changed the title Loading a large amount of images crashes Godot Single SVG file crashes Godot Nov 18, 2022
@metanoder
Copy link
Author

metanoder commented Nov 18, 2022

I isolated problem to a single SVG.

I've tried a number of content creation software to create SVGs (CCS = [Vectornator, Affinity Designer, and Inkscape])

my process for svg...
I copied file image from apple os by hitting command "I" on file folder.
Copy file icon from info tab popup.
opened CCS and paste.
Add star vector from CCS toolkit
export svg
import to godot resources folder
game crashes on open.

Project file zipped attached with svg from inkscape, but all svgs I've created with this crashed....
svgBug.zip

Further testing... Looks to be copying and pasting icons from MacOS icons.

Copied pasted from MacOS icons SVG all don't work...
inkscape...
inkscape_FileIcon

affinity designer...
affinity_designer_file_Icon

Vectornator...
vectornator_fileicon

Line traced version from Vectornator works...
noRasterSVG_Vectornator

@metanoder metanoder changed the title Single SVG file crashes Godot Single SVG file with containing MacOS icon, crashes Godot f Nov 18, 2022
@metanoder metanoder changed the title Single SVG file with containing MacOS icon, crashes Godot f Single SVG file containing MacOS icon, crashes Godot Nov 18, 2022
@akien-mga
Copy link
Member

It doesn't crash for me, but it fails importing the SVG indeed and enters a loop of attempting to reimport and failing:

ERROR: ImageLoaderSVG can't create image.
   at: create_image_from_string (modules/svg/image_loader_svg.cpp:112)
ERROR: Condition "p_image->is_empty()" is true. Returning: FAILED
   at: load_image (modules/svg/image_loader_svg.cpp:154)
ERROR: Error loading image: res://testingSVG_fromInkscape_0.svg
   at: load_image (core/io/image_loader.cpp:101)
ERROR: Error importing 'res://testingSVG_fromInkscape_0.svg'.
   at: _reimport_file (editor/editor_file_system.cpp:1909)
ERROR: ImageLoaderSVG can't create image.
   at: create_image_from_string (modules/svg/image_loader_svg.cpp:112)
ERROR: Condition "p_image->is_empty()" is true. Returning: FAILED
   at: load_image (modules/svg/image_loader_svg.cpp:154)
ERROR: Error loading image: res://testingSVG_fromInkscape_0.svg
   at: load_image (core/io/image_loader.cpp:101)
ERROR: Error importing 'res://testingSVG_fromInkscape_0.svg'.
   at: _reimport_file (editor/editor_file_system.cpp:1909)

The reimport loop issue is tracked in this issue: #62271.

But this issue here can focus on the SVG import failure.

@akien-mga akien-mga changed the title Single SVG file containing MacOS icon, crashes Godot Specific SVG file derived from macOS icon fails to be imported Nov 18, 2022
@akien-mga
Copy link
Member

So the macOS icon in that SVG is a PNG, so it seems we fail loading a SVG with a bundled PNG.
ThorVG has a PNG loader so it's probably a misuse of the API on our end.

@akien-mga akien-mga changed the title Specific SVG file derived from macOS icon fails to be imported Specific SVG file with bundled PNG image fails to be imported Nov 18, 2022
@akien-mga
Copy link
Member

Seems like the upstream test project svg2png can't process that file either and it crashes, so I reported it there: thorvg/thorvg#1278

@mgrudzinska
Copy link

@metanoder @akien-mga I hope the problem disappears after thorvg/thorvg#1279
also please check the thorvg/thorvg#1278 (comment)

@akien-mga
Copy link
Member

Thanks @mgrudzinska!

If I understand correctly, aside from that SVG being a pathological case, the problem in Godot might be that since the canvas area is empty (the actual PNG icon + vector graphics star icon being outside the canvas), we fail drawing because there's nothing to draw?

The failure in Godot happens here:

res = sw_canvas->draw();
if (res != tvg::Result::Success) {
memfree(buffer);
ERR_FAIL_MSG("ImageLoaderSVG can't create image.");
}

I assume this is then an expected error condition for SwCanvas::draw? https://samsung.github.io/thorvg/html/classtvg_1_1Canvas.html#aabf9e5a14da3b4bfd5883c2b4459abd0

I can try to improve the error handling here. Maybe we can also provide users with useful feedback that the canvas is empty before attempting to draw - is there any easy way to check that? (I haven't spent much time with thorvg myself yet, the implementation was done by @fire.)

@metanoder
Copy link
Author

metanoder commented Nov 23, 2022

@akien-mga

Yep, the file I uploaded is definitely "off" due to how I made it... that was my mistake.

However, I tried this in multiple instances without the canvas oversized / non-pathological and still crashes if used with MacOS icon copied from info tab.

svgbug_nov23.zip
Screenshot 2022-11-23 at 9 04 28 AM

Admittedly, after pinpointing it to a Mac folder icon, not exactly wide use case...
I'll just know that MacOS icons can't be coupled with PNGs in SVG format...

Thank you @akien-mga !!!

@akien-mga
Copy link
Member

However, I tried this in multiple instances without the canvas oversized / non-pathological and still crashes if used with MacOS icon copied from info tab.

svgbug_nov23.zip

I tested that SVG and it works fine here:
image

@metanoder
Copy link
Author

Thank you for checking. Sorry if this was all a fire drill.

Glad its not a problem. Maybe its my specific build with plugin...

@metanoder
Copy link
Author

metanoder commented Nov 23, 2022

For posterity...

Downloaded Godot 4 beta 6.
Tired opening it in PC. Ironically, it opens on Windows OS, but not on my MacOS version of Godot...

Looks like an obscure MacOS specific problem (which is my main development IDE). Note to self, leave MacOS icons alone.

Thanks again for taking the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants