Bug report #6855

SVG with map units crashes

Added by Bernhard Ströbl almost 7 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Symbology
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:15989

Description

To reproduce:
1) use an svg symbol for a polygon fill
2) set units to "Map untit"
3) zoom in and out (mouse wheel) until QGIS crashes or hangs

tried with 1.8 on WinXP and Linux(64 bit) and master on Linux(64 bit)
tried with different svg files

Associated revisions

Revision 6a936b93
Added by Larry Shaffer over 6 years ago

Draw SVG symbol from cached QImage unless it exceeds half of cache size, then use QPicture

- Fix #6855, SVG markers/fills larger than half cache (559^2 X 32 + SVG) are drawn with QPicture
- Fix #6861, make QPicture SVG symbols scale with Composer page zoom
- Fix #6861, make SVG symbol output to print/image more accurate by setting 'size' to double
- Update/add support for non-squared SVG via QImage and QPicture, on screen and in output to print/image
- Non-squared SVG QImage/QPicture can now be used in pattern fill, without excess space

History

#1 Updated by Larry Shaffer almost 7 years ago

  • Status changed from Open to Feedback
  • Target version set to Version 2.0.0

I have a fix for this in a pull request with other SVG symbol fixes:

https://github.com/qgis/Quantum-GIS/pull/353/commits (commit 33e16fd)

Basically, any SVG symbol stored in the QgsSvgCache as a QImage (default for non-rotated symbols) that is larger than 790 px X 790 px X 32 bit (for transparency) exceeds current cache size. When QgsSvgCache::trimToMaximumSize() was called after storing QImages that were larger than the cache, a very funky QImage was returned, causing the crash.

Now, when a SVG symbol's size would cause it's stored QImage to exceed the maximum cache size, a QPicture is saved instead, and that is used to render the symbol. QPicture is already used when a SVG symbol is rotated (QImage method produces jagged renderings), but is slower than rendering the cached QImage.

Now you should be able to excessively zoom into the SVG. Making sure the point feature is always in the extent, I have zoomed into a SVG symbol up to 5,000,000 ^ 2 virtual pixel area. At first the symbol is a QImage, then it becomes a QPicture. This increases the memory usage significantly (jumps to ~ 2 GB on my i7 iMac when way zoomed in). There should probably be a cap to the dimensional size of a SVG QPicture that is cached, maybe 10,000 ^ 2, which would then cache a null, 0/0 or very small transparent QPicture (or skip rendering the symbol completely).

#2 Updated by Bernhard Ströbl almost 7 years ago

Larry,

I am going to come back this issue when your pull requests have been merged. Anyways: do I understand that you would not recommend to use map units with svg symbols on low RAM (~1GB) machines (even after the fix)?

#3 Updated by Giovanni Manghi over 6 years ago

  • Operating System deleted (any)

Bernhard Ströbl wrote:

Larry,

I am going to come back this issue when your pull requests have been merged. Anyways: do I understand that you would not recommend to use map units with svg symbols on low RAM (~1GB) machines (even after the fix)?

the pull request have been committed, what is the status of this ticket?

#4 Updated by Larry Shaffer over 6 years ago

The fix has not been committed yet (latest pull request):

https://github.com/qgis/Quantum-GIS/pull/359

That request handles both marker and fill symbols, and keeps the RAM usage to a minimum (generally 300 MB to under 1 GB with heavy-to-full cache usage), and causes no crashes (at least on Mac). The code needs reviewed by Dr. Marco, since it is a significant change to how SVG symbols gets cached, and the memory management needs proofed as well.

#5 Updated by Giovanni Manghi over 6 years ago

  • Priority changed from Normal to High

#6 Updated by Larry Shaffer over 6 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF