Bug report #8411

Creating SVG image icons is slow in Print composer

Added by Pekka Sarkola about 6 years ago. Updated about 6 years ago.

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

Description

I create new print composer, then add Image. When I open "Search directories" to select SVG image, QGIS just start to create preview icons: this took hours.

QGIS is logging messages from QT: "QColor::setNamedColor:Unknown color name 'param(fill) #FFF', see image

Tested also in Ubuntu: works fine. In older version (1.8.0): works just fine. Qgis Master version 018e958

This blocks use of QGIS Print Composer (at least in my case)

SVGIcons.png (12.1 KB) Pekka Sarkola, 2013-08-05 01:02 AM

09.png (197 KB) Giovanni Manghi, 2013-08-05 10:51 AM

Associated revisions

Revision ee268984
Added by Nathan Woodrow about 6 years ago

Fix #8411

Suppress warnings for setNamedColour.
Warnings reneder composer unusable on windows, even for testing reasons.

Revision 33c288ad
Added by Nathan Woodrow about 6 years ago

Follow up for Fix #8411

History

#1 Updated by Giovanni Manghi about 6 years ago

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

Do you have additionals SVG files other than the ones installed by default? It is just a Windows issue, right?

#2 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Feedback to Open

Confirmed on Windows.

#3 Updated by Larry Shaffer about 6 years ago

No issue on Mac (10.7.5). May be the QSvgRenderer on Windows (Qt 4.7.1 ?) is having issues with the new SVG symbol library.

Do the same logged errors show up when the SVG previews are shown in symbology dialog?

#4 Updated by Giovanni Manghi about 6 years ago

Larry Shaffer wrote:

No issue on Mac (10.7.5). May be the QSvgRenderer on Windows (Qt 4.7.1 ?) is having issues with the new SVG symbol library.

Do the same logged errors show up when the SVG previews are shown in symbology dialog?

no.

Unrelated: see attached screenshot. Almost all svg symbols now render with no fill and a very clear outline, and they are hard to see. Is this right?

#5 Updated by Larry Shaffer about 6 years ago

Ok, I've tracked down the issue, but not sure how to fix it.

Running the following from PyQGIS shell, gives a similar Qt warning (output to the Log Messages panel):

from PyQt4.QtSvg import QSvgRenderer
QSvgRenderer("C:/OSGeo4W/apps/qgis-dev/svg/backgrounds/background_square.svg")

# which produces these warnings
QColor::setNamedColor: Unknown color name 'param(fill) #FFF'
QColor::setNamedColor: Unknown color name 'param(outline) #000'

When I removed all but that SVG file from the standard app SVG library, I got a repetition of 4 (8 total warnings) for testing and rendering that single file to the QgsComposerPictureWidget's icon view. This means the Log Messages panel is flooded with messages when trying to load all the default SVGs to the view. This is what causes the slowness, not necessarily the warnings themselves (at least I'm pretty sure).

The extra logging appears to be related to improvements Jürgen has done for Windows in main.cpp. The same issue might happen on Mac, except that loading the SVG file into the QSvgRenderer on Mac does not produce any warnings.

Those same Qt warnings also showed up when launching any project that already has a composer picture item in its layout, which, for some projects, slowed down their launching.

I was not able to determine why the QgsSvgCache rendered the same SVG file without logging those warnings. Also, I was not able to see how to disable those warnings specifically for QgsComposerPictureWidget::addDirectoryToPreview.

On a side note: this is not really a release blocker, since the flooding of warnings to Log Messages probably does not occur.

#6 Updated by Pekka Sarkola about 6 years ago

So, if slowness is coming from logging of warnings: workaround could be disable logging. Not very nice. Maybe there should be somewhere possibility to disable all loggings. IMHO: logging should be disabled by definition, only advanced users/developers need logging.

Reply to sidenote about blocker: maybe not for a release, but for my case. I wasn't sure what it means (blocker).

#7 Updated by Larry Shaffer about 6 years ago

Pekka Sarkola wrote:

So, if slowness is coming from logging of warnings: workaround could be disable logging. Not very nice. Maybe there should be somewhere possibility to disable all loggings. IMHO: logging should be disabled by definition, only advanced users/developers need logging.

Logging is disabled for the release builds. Generally, nightly builds of the master branch (like you are using) are built with debugging output on, because they are intended to be used for testing. If you took the current master and built it as a release variant, the problem would probably not present itself. I am assuming the issue of the SVG params not being read by the Windows QSvgRenderer has been around for quite some time, with new logging tools just having exposed it.

Not sure how to turn logging off for the debug builds, with regards to this issue, however. Still curious why those rendered SVGs in QgsSvgCache (canvas SVG marker symbology or the SVG picker in symbology) are not logging the warnings.

Reply to sidenote about blocker: maybe not for a release, but for my case. I wasn't sure what it means (blocker).

It's certainly a blocker for those using a debug build on Windows, though. :^)

#8 Updated by Nathan Woodrow about 6 years ago

  • Status changed from Open to Closed

#9 Updated by Nathan Woodrow about 6 years ago

This is fixed now by suppressing the warning for setNamedColor. It's not ideal but having a slow composer when using SVG isn't good because it can mask other issues.

#10 Updated by Larry Shaffer about 6 years ago

Thanks Nathan,

Maybe a more specific string comparison, so it doesn't mask other QColor::setNamedColor warnings/errors?

QColor::setNamedColor: Unknown color name 'param(

or, a regex comparison?

QColor::setNamedColor:[^']*'param\\(

Also available in: Atom PDF