Bug report #17705

QGIS crashes rendering temporary layers with spatial index

Added by Geo Dev over 6 years ago. Updated about 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Map Canvas
Affected QGIS version:master Regression?:Yes
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:25602

Description

The issue occurs zooming in/out temporary layers with spatial index containing many features that require a few moments to be completely rendered.

Steps to replicate the issue:
- create a temporary layer with a lot of features. For example, generate 100 000 points in the canvas extent using the tool "Random points in extent"
- starting from the zoom to extent, zoom out quickly with the mouse wheel (more zoom out steps at the same time): the canvas works as expected
- add the spatial index (Layer Properties -> General Tab -> Create spatial index) and repeat the previous step: QGIS crashes

Depending on the hardware performance, it may be necessary to increase the number of features since the issue occurs only if the rendering is not instantaneous.
The issue occurs both by enabling and disabling the parallel rendering and two different Stack Traces are reported.
It also occurs with QGIS 2.18.15 but it doesn't occur with QGIS 2.14.21 (regression) and it doesn't occur with any release of QGIS on Linux.

Stack Trace 1 - parallel rendering enabled

SpatialIndex::MVRTree::Data::storeToByteArray :
SpatialIndex::MVRTree::Data::storeToByteArray :
SpatialIndex::RTree::loadRTree :
SpatialIndex::RTree::loadRTree :
SpatialIndex::RTree::Data::getShape :
QgsSpatialIndex::intersects qgsspatialindex.cpp:354
QgsMemoryFeatureIterator::QgsMemoryFeatureIterator qgsmemoryfeatureiterator.cpp:64
QgsMemoryFeatureSource::getFeatures qgsmemoryfeatureiterator.cpp:245
QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator qgsvectorlayerfeatureiterator.cpp:258
QgsVectorLayerFeatureSource::getFeatures qgsvectorlayerfeatureiterator.cpp:97
QgsVectorLayerRenderer::render qgsvectorlayerrenderer.cpp:237
QgsMapRendererParallelJob::renderLayerStatic qgsmaprendererparalleljob.cpp:256
QtConcurrent::FunctionWrapper1<void,LayerRenderJob & __ptr64>::operator() qtconcurrentfunctionwrappers.h:84
QtConcurrent::MapKernel<QList<LayerRenderJob>::iterator,QtConcurrent::FunctionWrapper1<void,LayerRenderJob & __ptr64> >::runIteration qtconcurrentmapkernel.h:70
QtConcurrent::MapKernel<QList<LayerRenderJob>::iterator,QtConcurrent::FunctionWrapper1<void,LayerRenderJob & __ptr64> >::runIterations qtconcurrentmapkernel.h:79
QtConcurrent::IterateKernel<QList<LayerRenderJob>::iterator,void>::forThreadFunction qtconcurrentiteratekernel.h:256
QtConcurrent::IterateKernel<QList<LayerRenderJob>::iterator,void>::threadFunction qtconcurrentiteratekernel.h:218
QtConcurrent::ThreadEngineBase::run :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

Stack Trace 2 - parallel rendering disabled

SpatialIndex::MVRTree::Data::storeToByteArray :
SpatialIndex::MVRTree::Data::storeToByteArray :
SpatialIndex::RTree::loadRTree :
SpatialIndex::RTree::loadRTree :
SpatialIndex::RTree::Data::getShape :
QgsSpatialIndex::intersects qgsspatialindex.cpp:354
QgsMemoryFeatureIterator::QgsMemoryFeatureIterator qgsmemoryfeatureiterator.cpp:64
QgsMemoryFeatureSource::getFeatures qgsmemoryfeatureiterator.cpp:245
QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator qgsvectorlayerfeatureiterator.cpp:258
QgsVectorLayerFeatureSource::getFeatures qgsvectorlayerfeatureiterator.cpp:97
QgsVectorLayerRenderer::render qgsvectorlayerrenderer.cpp:237
QgsMapRendererCustomPainterJob::doRender qgsmaprenderercustompainterjob.cpp:267
QgsMapRendererCustomPainterJob::staticRender qgsmaprenderercustompainterjob.cpp:216
QtConcurrent::StoredFunctorCall1<void,void (__cdecl*)(QgsMapRendererCustomPainterJob * __ptr64),QgsMapRendererCustomPainterJob * __ptr64>::runFunctor qtconcurrentstoredfunctioncall.h:432
QtConcurrent::RunFunctionTask<void>::run qtconcurrentrunbase.h:136
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 2.99.0-Master
QGIS code revision: bbf00279ad
Compiled against Qt: 5.9.2
Running against Qt: 5.9.2
Compiled against GDAL: 2.2.3
Running against GDAL: 2.2.3

Associated revisions

Revision 38062ec6
Added by Nyall Dawson over 6 years ago

Add test for indexed memory provider thread safety

Refs #17705

Revision 2e5d538a
Added by Nyall Dawson about 6 years ago

Fix memory layers with spatial index crash when rendering

Fixes #17705

History

#1 Updated by Nyall Dawson about 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

#2 Updated by Giovanni Manghi about 6 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF