Author Topic: Crash when using with SVG files  (Read 3687 times)

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Crash when using with SVG files
« on: October 01, 2022, 09:40:21 am »
I am adapting the code to HiDPI after wx3.1.6 using wxBitmapBundle (see ticket #1297 for details), and I have discovered that wxBitmapBundle::FromSVG() method produces random crashes because the underlying library (nanoSVG) is buggy:
  - first crash is in nsvg_Parse(). This only happens on non-english locales, is fixed in nanoSVG trunk but not in wxWidgets, and a workaround is locale switching before calling FromSVG().
  - second crash is in nsvg__addEdge(). AFAIK this is not fixed and there is no workaround.

Because of this, I will temporarily remove calls to wxBitmapBundle::FromSVG() along this weekend.

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: Crash when using with SVG files
« Reply #1 on: October 01, 2022, 10:46:51 am »
Straight up: I am not happy with the process used and the way the SVN changes have been made.
Going forward:
 Can a new interface be added so that the changes in the vast majority of code calls one function/class and this class/function has the smarts to either use the existing PNG or the new SVG files. This has the advantage on only modifying the existing code:
  • Once
  • Allows for the removal of the PNG support without changing the C::B source files
  • updates as needed without modifying the existing C::B code after the initial change.
  • Existing C::B code does not have any #if..#else..#endif block

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: Crash when using with SVG files
« Reply #2 on: October 02, 2022, 12:53:52 pm »
In my own software, I use wxBitmapBundle::FromSVGFile() in wxWidgets 3.2.1 and never met such problems (until now ???)
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Crash when using with SVG files
« Reply #3 on: October 02, 2022, 01:42:20 pm »
It was a misunderstanfing on my side, it is fixed now.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Crash when using with SVG files
« Reply #4 on: October 02, 2022, 04:53:36 pm »
It was a misunderstanfing on my side, it is fixed now.

Good work.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.