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.52k stars 2.99k forks source link

loading SELAFIN file with none dataset as vector layer causes QGIS to hang #45674

Closed nicogodet closed 2 years ago

nicogodet commented 3 years ago

What is the bug or the crash?

Tried on Windows and Linux and on both platform, QGIS hangs after drag & drop a SELAFIN meshlayer. It hangs with 100% CPU usage.

test_mesh_3.22.slf.zip

~~In general, Drag & Drop of meshlayer seems not well handle by QGIS. Dropping a TELEMAC .res open faces as polygon layer for each time step and vertices as point layer for each time step. Should I create another issue or do we make this current ticket more general ? image (The layer in screenshot can be sent by email if requested)~~ See first comment

Steps to reproduce the issue

Drag and drop a meshlayer in QGIS

Versions

3.22 Linux and Windows

Supported QGIS version

New profile

Additional context

No response

vcloarec commented 3 years ago

.res file is not supported by MDAL but seems supported by GDAL, that's why you 've got layer for each time step.

vcloarec commented 3 years ago

@nicogodet , I can't open the zip file.

nicogodet commented 3 years ago

@vcloarec Just remove .zip from filename. It's not an archive, just a github hack

vcloarec commented 2 years ago

no problem with 3.22 self built on kubuntu: selafin_322

nicogodet commented 2 years ago

Drag & Drop from *outside QGIS

From browser, I confirm it's OK.

saberraz commented 2 years ago

I can confirm the issue. It either crashes immediately or at some later stage during zooming/panning/editing.

vcloarec commented 2 years ago

Confirmed, but on my side I've got a freeze without crash. It seems that QGIS tries to open it with OGR provider before trying as mesh layer.

It seems that it is the OGR provider that can't handle with it.

vcloarec commented 2 years ago

The issue is at the level of the OGR provider, maybe because the Selafin files doesn't have dataset. I wonder if Selafin files allow only mesh frame without any dataset. If yes, this is an OGR issue, if not, it is a MDAL issue because MDAL has to write a least one dataset group in Selafin file. @nicogodet , can TELEMAC produce Selafin files without dataset ?

saberraz commented 2 years ago

Vincent, I think the issue can be also reproduced with a 2dm file too.

vcloarec commented 2 years ago

@saber, no problem on my side with 2dm, but freeze when trying loading the file as vector layer.

nicogodet commented 2 years ago

@vcloarec TELEMAC can not produce SELAFIN/SERAFIN without dataset.

But TELEMAC is not used to create the mesh frame. It is only used to run computation. Meshers like BlueKenue, Basemesh or SalomeHydro (EDF) are used to create the SELAFIN and these mesher can produce SELAFIN without dataset.

nicogodet commented 2 years ago

BTW

.res file is not supported by MDAL

It should as the extension of SELAFIN file is useless. .slf, .ser, .res, .geo are common extensions for SELAFIN/SERAFIN but sometimes no extension at all. But I guess it becomes difficult to guess the file type if extensions may vary form user to user...

vcloarec commented 2 years ago

But I guess it becomes difficult to guess the file type if extensions may vary form user to user...

MDAL does not use the extension but try to read the file. If the file are the same inside (res/slf), MDAL could read *.res file..

and these mesher can produce SELAFIN without dataset.

So maybe it is an OGR issue... Debugging with this Selafin files, OGR provider detects more than 300 000 sublayers...

vcloarec commented 2 years ago

@nicogodet , can you share the *.res file?

nicogodet commented 2 years ago

Provide an email as I can send you an download link tomorrow. I can't share it publicly.

In the mean time, I think you can try with validation result file from TELEMAC validation test suite : https://gitlab.pam-retd.fr/otm/telemac-mascaret/-/tree/main/examples/telemac2d/malpasset f2d_**.slf are result file with the last time step only.

nicogodet commented 2 years ago
vcloarec commented 2 years ago

@nicogodet I confirm, for file with none dataset, it is an OGR issue that can't handle this case. When dropping the file in QGIS, some providers try to look in supported file to find sublayers. When debugging, I see that OGR provider finds in this file more than 300 000 sublayers... so that create this freeze when handling with all this sub layers or, I think, the crash on your side.

For *.res file, indeed, you are right, even if MDAL can read it, QGIS filters the file with their extension comparing with extension provided by MDAL. So, if '*.res' or other extension has to be read by MDAL, it is an MDAL issue, you can feel a ticket in the MDAL repo.

nicogodet commented 2 years ago

@vcloarec That's strange that OGR find a lot of sublayers...

For *.res, I think it could be part of a larger improvement regarding SELAFIN reading by MDAL with https://github.com/lutraconsulting/MDAL/issues/286 Making MDAL less strict when reading SELAFINs

vcloarec commented 2 years ago

upstream bug in OGR fixed by https://github.com/OSGeo/gdal/pull/4945