[QGIS-Developer] Rendering (simple) labels before background raster layer finishes?

Nyall Dawson nyall.dawson at gmail.com
Thu Sep 9 16:21:06 PDT 2021


On Thu, 9 Sept 2021 at 18:07, Johannes Kröger (WhereGroup)
<johannes.kroeger at wheregroup.com> wrote:
>
> Hey list,
>
> I have a fast vector layer in the foreground and a slow raster tile
> layer in the background. The vector layer has some simple labels.
> Neither layer uses any blending modes to my knowledge.
>
> For rendering the labels QGIS waits until the layers have finished
> rendering which takes a while.
> Our users can use the labels to orient themselves and to decide where to
> pan and zoom.
> They could work faster if the labels would appear early on, before the
> slow raster layer finished rendering.

Yep, Mathieu (@nirvn) and I have previously discussed this, and it's
an artificial constraint which should definitely be removed. There's
no reason we can't start rendering labels as soon as all the layers
which are participating in the label results are rendered, and then
continue rendering other slow layers (rasters, point clouds, mesh,
non-labeled vectors) in the background while the labeling calculates
and renders.

It's not a trivial change unfortunately, which is the only reason it's
still acting like it is and neither Mathieu or I have just fixed it
ourselves out of our own personal frustration! I'd estimate 3-4 days
developer effort to implement in the QGIS code and refactor all the
necessary pathways to allow this optimisation. (Mail me off-list if
you'd like to discuss sponsoring this change!)

Nyall



>
> So I would like to have the labels render earlier, before the raster
> layer finishes loading, and then "just" composite(?) the scene for the
> final canvas image when done. Is there a reasonable way in PyQGIS to
> achieve that?
>
> When I manually disable the raster layer, move the map, let it finish
> rendering (so the vector data and labels are visible) and then re-enable
> the raster layer, it plops up in the background without the labels being
> visibly re-rendered themselves so it seems technically possible.
>
> As a hacky approach I tried disabling the raster layer right when the
> https://qgis.org/pyqgis/master/gui/QgsMapCanvas.html#qgis.gui.QgsMapCanvas.renderStarting
> signal, then re-enabling it when the render is done but of course that
> introduces "white flashes" from the background vanishing, then
> reappearing. Maybe it would be possible to tell QGIS to not request any
> new data/render for the raster layer for a while but use the cached
> render it currently has until the labels are done, then fetch and render
> for the updated extents?
>
> Cheers, Hannes
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list