qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.61k stars 3.01k forks source link

3D Map View crashes QGIS when project uses UTM projection #41171

Open kannes opened 3 years ago

kannes commented 3 years ago

Describe the bug QGIS crashes when I try to display the included "world" geodata in 3D using a UTM projection.

How to Reproduce

  1. Enter "world" in the coordinate display to load the example data
  2. Set the project CRS to EPSG:25832 (ETRS89/UTM 32N, also reproduced with EPSG:32635 (WGS84/UTM 35N) and EPSG:32178 (WGS84/UTM 18S)
  3. Set the layer to render in 3D (Single Symbol)
  4. Open a 3D Map View
  5. QGIS crashes

Backtrace

Thread 15 "Thread (pooled)" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffba7fc640 (LWP 79190)]
0x00007ffff48babe3 in p2t::Sweep::NewFrontTriangle (this=0x7fffa44527e0, tcx=..., point=..., node=...) at /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc:181
181 /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc: No such file or directory.
(gdb) bt
#0  0x00007ffff48babe3 in p2t::Sweep::NewFrontTriangle(p2t::SweepContext&, p2t::Point&, p2t::Node&) (this=0x7fffa44527e0, tcx=..., point=..., node=...)
    at /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc:181
#1  0x00007ffff48bad11 in p2t::Sweep::PointEvent(p2t::SweepContext&, p2t::Point&) (this=this@entry=0x7fffa44527e0, tcx=..., point=...)
    at /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc:79
#2  0x00007ffff48badb5 in p2t::Sweep::SweepPoints(p2t::SweepContext&) (this=this@entry=0x7fffa44527e0, tcx=...)
    at /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc:56
#3  0x00007ffff48bae5a in p2t::Sweep::Triangulate(p2t::SweepContext&) (this=0x7fffa44527e0, tcx=...) at /usr/src/debug/qgis/external/poly2tri/sweep/sweep.cc:47
#4  0x00007ffff48b7310 in p2t::CDT::Triangulate() (this=this@entry=0x55555af8da90) at /usr/src/debug/qgis/external/poly2tri/sweep/cdt.cc:52
#5  0x00007ffff43fdddb in QgsTessellator::addPolygon(QgsPolygon const&, float) (this=0x55555f1353c0, polygon=..., extrusionHeight=extrusionHeight@entry=100)
    at /usr/src/debug/qgis/src/core/qgstessellator.cpp:722
#6  0x00007ffff2d77722 in QgsPolygon3DSymbolHandler::processPolygon(QgsPolygon*, long long, float, float, Qgs3DRenderContext const&, QgsPolygon3DSymbolHandler::PolygonData&) (this=0x55555f2d2bd0, polyClone=0x7fffa4452ee0, fid=36, height=0, extrusionHeight=100, context=..., out=...) at /usr/include/c++/10.2.0/bits/unique_ptr.h:173
#7  0x00007ffff2d7879f in QgsPolygon3DSymbolHandler::processFeature(QgsFeature const&, Qgs3DRenderContext const&) (this=0x55555f2d2bd0, f=..., context=...)
    at /usr/src/debug/qgis/src/3d/symbols/qgspolygon3dsymbol_p.cpp:194
#8  0x00007ffff2d4df56 in operator()() const (__closure=0x55555b077950) at /usr/src/debug/qgis/src/3d/qgsvectorlayerchunkloader_p.cpp:98
#9  0x00007ffff2d4bc45 in non-virtual thunk to QtConcurrent::RunFunctionTask<void>::run() () at /usr/include/qt/QtConcurrent/qtconcurrentrunbase.h:140
#10 0x00007ffff531d302 in  () at /usr/lib/libQt5Core.so.5
#11 0x00007ffff5319f0f in  () at /usr/lib/libQt5Core.so.5
#12 0x00007ffff52333e9 in start_thread () at /usr/lib/libpthread.so.0
#13 0x00007ffff342f293 in clone () at /usr/lib/libc.so.6

QGIS and OS versions

QGIS version 3.17.0-Master QGIS code revision 375764d8df
Compiled against Qt 5.15.2 Running against Qt 5.15.2
Compiled against GDAL/OGR 3.3.0dev-62626e4f7a-dirty Running against GDAL/OGR 3.3.0dev-62626e4f7a-dirty
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.34.1 Running against SQLite 3.34.1
PostgreSQL Client Version 13.1 SpatiaLite Version 4.3.0a
QWT Version 6.1.6 QScintilla2 Version 2.11.6
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version Arch Linux This copy of QGIS writes debugging output.
gioman commented 3 years ago
3\. Set the layer to render in 3D (Single Symbol)

@kannes can you attach it?

kannes commented 3 years ago

The layer you mean? In Step 1 I loaded the "world" layer using the easter egg. This comes with QGIS itself :)

gioman commented 3 years ago

The layer you mean? In Step 1 I loaded the "world" layer using the easter egg. This comes with QGIS itself :)

@kannes right, sorry. Anyway... the layer is global with CRS in degrees. There is a limit to the extent you can reproject in a "local" CRS like UTM. This by itself can cause QGIS eat up a lot of memory and eventually even crash. Said that no crash here on Ubuntu 20.04 and QGIS 3.16 installed with qgis.org's repos (I also think that the 3D symbology is not meant to be used on a layer with a CRS in degrees).

kannes commented 3 years ago

I know but that should still not happen ;)

No crash for you using the exact same data and CRS?

gioman commented 3 years ago

I know but that should still not happen ;)

of course

No crash for you using the exact same data and CRS?

no. You may want to attach a project, so we are sure we are using the same configs.

jgrocha commented 3 years ago

I was not able to crash QGIS (with current master) using the same steps, using UTM 29N projected coordinate system. I've attached a print screen.

In this case, if QGIS crashes, it is good feedback for the user: what he is trying to do might not be reasonable. The only thing we could do is to issue a warning when the data used is beyond the limits of the CRS used to render the data.

Captura de ecrã de 2021-01-31 16-22-44

gioman commented 3 years ago

The only thing we could do is to issue a warning when the data used is beyond the limits of the CRS used to render the data.

@jgrocha yes, even without considering 3d symbology and 3d views, there is a lot of people that adds a global layer into a project with a local CRS the it zooms to full and gets into trouble (blaming QGIS along the way).

kannes commented 3 years ago

Thanks for testing! I attached a project file: crash.zip

I hope that is the right file. It seems to be the one that QGIS loads for the "world" easter egg.

It crashes for me with master from right now: QGIS version | 3.17.0-Master | QGIS code revision | d1409703fbc

@jgrocha Crashes should never happen. Imagine a user who worked a whole day on something without saving (stupid yes, but no reason to disregard their work) and then just by clicking the wrong button their QGIS would crash without warning. ;)

gioman commented 3 years ago

Thanks for testing! I attached a project file: crash.zip

@kannes still no crash here on QGIS master on Ubuntu 20.04.

github-actions[bot] commented 3 years ago

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.

kannes commented 3 years ago

Still crashes for me with:

QGIS version 3.19.0-Master QGIS code revision 002e634dba5
Compiled against Qt 5.15.2 Running against Qt 5.15.2
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.34.1 Running against SQLite 3.34.1
PostgreSQL Client Version 13.2 SpatiaLite Version 4.3.0a
QWT Version 6.1.6 QScintilla2 Version 2.11.6
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version Arch Linux
gioman commented 3 years ago

Arch Linux

@kannes can you test on a another OS?

kannes commented 3 years ago

Tried the standalone 3.18 on Windows 10 on a Intel laptop. It did not crash immediately, the 3D appeared to do something, then I got multiple crash dialogs with:

Report Details #1

Stack Trace

QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsTessellator::addPolygon :
QgsPolygon3DSymbol::writeXml :
QgsPolygon3DSymbol::writeXml :
QgsVectorLayer3DRenderer::writeXml :
QgsRuleBased3DRenderer::writeXml :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info QGIS Version: 3.18.0-Z�rich QGIS code revision: bdef9fb328 Compiled against Qt: 5.11.2 Running against Qt: 5.11.2 Compiled against GDAL: 3.1.4 Running against GDAL: 3.1.4

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

Report Details #2

Stack Trace

QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsUserProfileManager::settingsFile :
QgsTessellator::addPolygon :
QgsPolygon3DSymbolHandler::processPolygon qgspolygon3dsymbol_p.cpp:146
QgsPolygon3DSymbolHandler::processFeature qgspolygon3dsymbol_p.cpp:191
::operator() qgsvectorlayerchunkloader_p.cpp:93
QtConcurrent::RunFunctionTask::run qtconcurrentrunbase.h:136
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :
kannes commented 3 years ago

As I tried to kill it (it was still in the task bar), another dialog:

User Feedback

asd

Report Details

Crash ID: 93cd8c9ce9aaf89a4ada4a67fb7062b0a40b7f67

Stack Trace

p2t::Sweep::NewFrontTriangle sweep.cc:181
p2t::Sweep::PointEvent sweep.cc:83
p2t::Sweep::SweepPoints sweep.cc:57
p2t::Sweep::Triangulate sweep.cc:49
QgsTessellator::addPolygon qgstessellator.cpp:724
QgsPolygon3DSymbolHandler::processPolygon qgspolygon3dsymbol_p.cpp:146
QgsPolygon3DSymbolHandler::processFeature qgspolygon3dsymbol_p.cpp:191
::operator() qgsvectorlayerchunkloader_p.cpp:93
QtConcurrent::RunFunctionTask::run qtconcurrentrunbase.h:136
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info QGIS Version: 3.18.0-Z�rich QGIS code revision: bdef9fb328 Compiled against Qt: 5.11.2 Running against Qt: 5.11.2 Compiled against GDAL: 3.1.4 Running against GDAL: 3.1.4

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

wonder-sk commented 3 years ago

I can't replicate on master / ubuntu 20.04 unfortunately... the backtrace looks reasonable though - a crash in the tesselator code.

The problem is mainly that QGIS itself does not handle well reprojection problems, so even the 2D map gets corrupted with all sorts of graphical errors. In an ideal world, in QGIS we should have some clipping implemented that would clip geometries to areas that are valid for the given transformation - after that, other parts of QGIS (including the tessellator) should behave better, without rendering errors or crashes.

Pedro-Murteira commented 2 years ago

I've tested this issue on QGIS 3.22.4 and 3.24.0. The 3d map view does not fully render the layers, which might be caused by the reprojection, still, I'm not being able to reproduce the crash itself. Hello @kannes, did you come across this bug in more recent versions?

kannes commented 2 years ago

No immediate crash for me in a recent master build anymore. I get two red warnings, which might be catching what had crashed earlier:

Qt: oops... this should not happen! couldn't determine near/far plane. defaulting to 1...1e9
Qt: camera position got NaN!

It crashed some moments later though after I moved rightdrag and leftdrag around a bit in the map and used zoom to scene.


Thread 1 "qgis-git" received signal SIGSEGV, Segmentation fault.
0x00007fff2fb9e0ac in ?? () from /usr/lib/qt/plugins/renderers/libopenglrenderer.so
(gdb) bt
#0  0x00007fff2fb9e0ac in  () at /usr/lib/qt/plugins/renderers/libopenglrenderer.so
#1  0x00007fff2fbbcec0 in  () at /usr/lib/qt/plugins/renderers/libopenglrenderer.so
#2  0x00007fffeaec879b in  () at /usr/lib/libQt53DCore.so.5
#3  0x00007fffeaed67e2 in Qt3DCore::QAspectManager::processFrame() () at /usr/lib/libQt53DCore.so.5
#4  0x00007fffeaed696b in  () at /usr/lib/libQt53DCore.so.5
#5  0x00007ffff4fd59d3 in  () at /usr/lib/libQt5Core.so.5
#6  0x00007ffff4de879c in  () at /usr/lib/libQt5Core.so.5
#7  0x00007ffff4de8a3e in  () at /usr/lib/libQt5Core.so.5
#8  0x00007ffff4de3d53 in QUnifiedTimer::updateAnimationTimers(long long) () at /usr/lib/libQt5Core.so.5
#9  0x00007ffff4de7233 in QAnimationDriver::advanceAnimation(long long) () at /usr/lib/libQt5Core.so.5
#10 0x00007ffff4fc8d56 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#11 0x00007ffff5a191a6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#12 0x00007ffff3287744 in QgsApplication::notify(QObject*, QEvent*) (this=0x7fffffffd310, receiver=0x55555b9443c8, event=0x7fffffffccc0)
    at /usr/src/debug/qgis/src/core/qgsapplication.cpp:515
#13 0x00007ffff4fa4b9a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#14 0x00007ffff4ff0335 in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
#15 0x00007ffff4ff0962 in  () at /usr/lib/libQt5Core.so.5
#16 0x00007fffe9d05f13 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#17 0x00007fffe9d5c0d9 in  () at /usr/lib/libglib-2.0.so.0
#18 0x00007fffe9d03485 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#19 0x00007ffff4ff0ada in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#20 0x00007ffff4f9ce6b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#21 0x00007ffff4fa85c7 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#22 0x0000555555560886 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/qgis/src/app/main.cpp:1683