opengisch / qfieldsync

Sync your projects to QField on android
GNU Lesser General Public License v3.0
51 stars 25 forks source link

QGIS crash when syncing with cable and layer feature count enabled #588

Open meyerlor opened 2 weeks ago

meyerlor commented 2 weeks ago

Last week the first project which always worked flawlessly suddenly stopped working - whenever i export the project to Qfield (via cable), QGIS crashes. Nothing major changed in the project file. This is the error stack of QGIS:

Maybe noteworthy: It is a QfieldCloud project - for testing new functions i wanted to export it via cable before rolling it out via cloud.

Report Details

Python Stack Trace

Windows fatal exception: code 0xc0000139

Thread 0x00001420 (most recent call first):
  <no Python frame>
Windows fatal exception: code 0xc0000139

Thread 0x00001420 (most recent call first):
  <no Python frame>
Windows fatal exception: access violation

Thread 0x00001420 (most recent call first):
  File "C:\Users/mey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qfieldsync\gui\package_dialog.py", line 177 in package_project
    offline_convertor.convert()

Stack Trace


QgsVectorLayer::aggregate :
QgsExpression::cleanRegisteredFunctions :
QgsFieldFormatter::createCache :
QgsExpressionFunction::run :
QgsExpressionNodeFunction::evalNode :
QgsExpressionNode::eval :
QgsExpressionFunction::run :
QgsExpressionNodeFunction::evalNode :
QgsExpressionNode::eval :
QgsExpressionFunction::run :
QgsExpressionNodeFunction::evalNode :
QgsExpressionNode::eval :
QgsExpressionFunction::run :
QgsExpressionNodeFunction::evalNode :
QgsExpressionNode::eval :
QgsExpressionNodeBinaryOperator::evalNode :
QgsExpressionNode::eval :
QgsExpressionNodeBinaryOperator::evalNode :
QgsExpressionNode::eval :
QgsExpressionNodeCondition::evalNode :
QgsExpressionNode::eval :
QgsExpression::evaluate :
QgsCategorizedSymbolRenderer::valueForFeature :
QgsCategorizedSymbolRenderer::legendKeysForFeature :
QgsVectorLayerFeatureCounter::run :
QgsTask::start :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info QGIS Version: 3.36.3-Maidenhead QGIS code revision: 2df96554 Compiled against Qt: 5.15.13 Running against Qt: 5.15.13 Compiled against GDAL: 3.9.0 Running against GDAL: 3.9.0

System Info CPU Type: x86_64 Kernel Type: winnt Kernel Version: 10.0.19045

I tried to export the project into different directorys (where i definitely have write access) with no success. I'll gladly give you the non-working project fiel/data if you are interested (or provide more logs if you point me to where to collect them)

suricactus commented 2 weeks ago

Hey, @meyerlor. Thanks for reporting! Would be great if you share with us a sample project, so we can try to reproduce on our machines. Do you have the problem with all projects, or only this particular one? And if possible, can you try with a different version of QGIS? It sounds like a QGIS regression.

suricactus commented 1 week ago

@meyerlor one other idea to see more details of the crash. Can you please install a QGIS version with debugging enabled? You can find such version in osgeo4w behind a package named qgis-xxx-pdb where xxx is the QGIS version, e.g. 3.36.3. ALternatively, if you install the qgis-nightly package, you may have the debugging too (not sure about the second one).

meyerlor commented 1 week ago

@suricatus thanks for your time! i removed step by step all layers of the project- the layer Bäumeseems to be the troublemaker, when i empty it (but leave it in the project) i can sync again. QGIS.zip

I installed the qgis-ltr-pdb 3.34.7-2 via the OSGeo4W setup but i did not find a new symbol to launch qgis in debugging mode - how would i have to proceed from there?

m-kuhn commented 1 week ago

Hi @meyerlor First: thank you for helping with debugging! Just follow the same steps again to make it crash, with the -pdb package installed, post the stack trace from your first report above again, it should now contain more information.

meyerlor commented 1 week ago

Ah, indeed it does! Thanks for the pointer!

Report Details

Python Stack Trace

Windows fatal exception: access violation

Thread 0x00003394 (most recent call first):
  File "C:\Users/mey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qfieldsync\gui\package_dialog.py", line 177 in package_project
    offline_convertor.convert()

Stack Trace


QgsVectorLayer::aggregate qgsvectorlayer.cpp:4911
fcnAggregateRelation qgsexpressionfunction.cpp:894
QgsStaticExpressionFunction::func qgsexpressionfunction.h:469
QgsExpressionFunction::run qgsexpressionfunction.cpp:120
QgsExpressionNodeFunction::evalNode qgsexpressionnodeimpl.cpp:1063
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpressionFunction::run qgsexpressionfunction.cpp:109
QgsExpressionNodeFunction::evalNode qgsexpressionnodeimpl.cpp:1063
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpressionFunction::run qgsexpressionfunction.cpp:109
QgsExpressionNodeFunction::evalNode qgsexpressionnodeimpl.cpp:1063
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpressionFunction::run qgsexpressionfunction.cpp:109
QgsExpressionNodeFunction::evalNode qgsexpressionnodeimpl.cpp:1063
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpressionNodeBinaryOperator::evalNode qgsexpressionnodeimpl.cpp:207
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpressionNodeCondition::evalNode qgsexpressionnodeimpl.cpp:1587
QgsExpressionNode::eval qgsexpressionnode.cpp:33
QgsExpression::evaluate qgsexpression.cpp:397
QgsCategorizedSymbolRenderer::valueForFeature qgscategorizedsymbolrenderer.cpp:301
QgsCategorizedSymbolRenderer::legendKeysForFeature qgscategorizedsymbolrenderer.cpp:1132
QgsVectorLayerFeatureCounter::run qgsvectorlayerfeaturecounter.cpp:82
QgsTask::start qgstaskmanager.cpp:81
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info QGIS Version: 3.34.7-Prizren QGIS code revision: 6f7d735c Compiled against Qt: 5.15.13 Running against Qt: 5.15.13 Compiled against GDAL: 3.9.0 Running against GDAL: 3.9.0

System Info CPU Type: x86_64 Kernel Type: winnt Kernel Version: 10.0.19045

m-kuhn commented 1 week ago

Thanks. The source of the problem is this comment in the QGIS code: https://github.com/qgis/QGIS/blob/43e7d18cd89c25a7ca107185e1d4708abea44234/src/core/vector/qgsvectorlayer.cpp#L5097-L5098

As a workaround: can you try disable "show feature count" ("Objektanzahl anzeigen" below) on that layer?

image

meyerlor commented 1 week ago

That does the trick! Feature count is not really neccessary here so that's a good workaround for now! Thanks alot!

suricactus commented 1 week ago

@meyerlor thanks for testing and debugging with us! Unfortunately this is an upstream bug within QGIS, which proved to be very tricky to solve there. We can try to outsmart it within QFieldSync by temporarily disabling feature count within QFieldSync during packaging. I don't want to promise a specific timeframe when this will land in QFieldSync.