qfieldsync icon indicating copy to clipboard operation
qfieldsync copied to clipboard

QGIS crash when syncing with cable and layer feature count enabled

Open meyerlor opened this issue 1 year ago • 10 comments

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)

meyerlor avatar Jun 10 '24 07:06 meyerlor

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 avatar Jun 14 '24 10:06 suricactus

@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).

suricactus avatar Jun 18 '24 00:06 suricactus

@suricatus thanks for your time! i removed step by step all layers of the project- the layer Bäume seems 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?

meyerlor avatar Jun 18 '24 06:06 meyerlor

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.

m-kuhn avatar Jun 18 '24 08:06 m-kuhn

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

meyerlor avatar Jun 18 '24 08:06 meyerlor

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

m-kuhn avatar Jun 18 '24 09:06 m-kuhn

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

meyerlor avatar Jun 18 '24 09:06 meyerlor

@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.

suricactus avatar Jun 18 '24 10:06 suricactus

The QField docs don't say that you have to disable feature count (or when you do). I have it on routinely and it never occured to me that it would cause trouble.

gdt avatar Oct 09 '25 00:10 gdt

Is this really an upstream qgis bug? qgis says that you can't access some things from other threads, and it's not clear if that's what is happening. (Yes, I know threaded code is super hard.) There' s no link in this issue to an open qgis issue.

gdt avatar Oct 09 '25 00:10 gdt