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.39k stars 2.98k forks source link

Incompatible layer set as "elevation surface" causes "Global Map Shading" to crash QGIS #53176

Closed AlisterH closed 1 year ago

AlisterH commented 1 year ago

What is the bug or the crash?

"Global map shading" causes QGIS to crash if an unsuitable layer has elevationProperties enabled.

Steps to reproduce the issue

  1. Add a layer to QGIS using Quick Map Services plugin (this is simply a convenient way to get an unsuitable layer to reproduce the crash - the plugin itself is not necessary to cause the crash).
  2. In the Elevation tab in the layer properties, enable "Represents Elevation Surface". This could also be done programmatically, perhaps even in a plugin.
  3. With the web map layer turned on, select any layer and in the layer styling panel click on the Shading Renderer tab: image
  4. Enable "Global Map Shading".
  5. QGIS will crash.

Alternatively, with the web map layer turned off, enable "Global Map Shading", then turn the layer on and it will crash.

Versions

QGIS version 3.30.2-'s-Hertogenbosch QGIS code revision 0992b533 Qt version 5.15.3 Python version 3.9.5 GDAL/OGR version 3.6.4 PROJ version 9.2.0 EPSG Registry database version v10.082 (2023-02-06) GEOS version 3.11.2-CAPI-1.17.2 SQLite version 3.41.1 PDAL version 2.5.2 PostgreSQL client version unknown SpatiaLite version 5.0.1 QWT version 6.1.6 QScintilla2 version 2.13.1 OS version Windows 10 Version 2009

Active Python plugins annotationManager 0.5 annotation_labels 1.0.1 AnotherDXF2Shape 1.2.7 changeDataSource 3.1 coveragebuilder version 0.5.0 Equal_area_slope_QGIS_Plugin 0.1 file_management 0.1 geometry_paster 0.2 joinmultiplelines Version 0.4.1 layout_panel-main 0.3 MemoryLayerSaver 4.0.4 nominatim 1.4.5 pathfinder version 0.4.2 plugin_reloader 0.9.3 precisioncursor4qgis-main 0.2E QCopycanvas 0.7 qgis_resource_sharing 1.0.0 valuetool 3.0.15 workbench 0.0.4 db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99 civilplan 1.0 quick_map_services 0.19.33

Supported QGIS version

New profile

Additional context

Python Stack Trace
Windows fatal exception: access violation

Thread 0x00005714 (most recent call first):

Stack Trace

CPLODBCDriverInstaller::RemoveDriver :
CPLODBCDriverInstaller::RemoveDriver :
CPLODBCDriverInstaller::RemoveDriver :
CPLODBCDriverInstaller::RemoveDriver :
resampleSingleBandRasterStatic qgsgdalutils.cpp:278
QgsGdalUtils::resampleSingleBandRaster qgsgdalutils.cpp:305
QgsRasterLayerRenderer::drawElevationMap qgsrasterlayerrenderer.cpp:520
QgsRasterLayerRenderer::render qgsrasterlayerrenderer.cpp:372
QgsMapRendererParallelJob::renderLayerStatic qgsmaprendererparalleljob.cpp:373
QtConcurrent::MapKernel > > > >,QtConcurrent::FunctionWrapper1QtConcurrent::MapKernel > >,QtConcurrent::FunctionWrapper1 >::runIterations qtconcurrentmapkernel.h:78
QtConcurrent::IterateKernel > >,void>::threadFunction qtconcurrentiteratekernel.h:217
QtConcurrent::ThreadEngineBase::run :
QThreadPoolPrivate::reset :
QThread::start :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.30.2-'s-Hertogenbosch
QGIS code revision: 0992b533
Compiled against Qt: 5.15.3
Running against Qt: 5.15.3
Compiled against GDAL: 3.6.4
Running against GDAL: 3.6.4

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.19045
vcloarec commented 1 year ago

Hi @AlisterH , can you give more details about the layer that leads to this crash?

AlisterH commented 1 year ago

I believe it occurs with any layer added by the Quick Map Services plugin. e.g.

General
Name    Google Satellite
URL https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
Source  type=xyz&zmin=0&zmax=20&url=https://mt1.google.com/vt/lyrs%3Ds%26x%3D{x}%26y%3D{y}%26z%3D{z}
Provider    wms

Information from provider
Extent  -20037508.3427892439067364,-20037508.3427892476320267 : 20037508.3427892439067364,20037508.3427892476320267
Width   n/a
Height  n/a
Data type   Could not determine raster data type.
WMS Info    
 Tile Layer Properties  Cache Stats 
Server Properties
Property    Value
WMS Version 
Title   
Abstract    
Keywords    
Online Resource -
Contact Person  

Fees    
Access Constraints  
GetCapabilitiesUrl  https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
GetMapUrl   https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
GetFeatureInfoUrl   https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
GetLegendGraphic    
Tile Layer Count    1
GetTileUrl  
Tile templates  
FeatureInfo templates   
Identify Formats    
Tileset Properties
Identifier  Tile mode
xyz XYZ
Property    Value
Title   
Abstract    
Selected    Yes
CRS 
CRS Bounding Box
EPSG:3857   -20037508.3427892439067364,-20037508.3427892476320267 : 20037508.3427892439067364,20037508.3427892476320267
Available Tilesets  tms0
Selected tile matrix set tms0
Scale   Tile size [px]  Tile size [mu]  Matrix size Matrix extent [mu]  Bounds
Width   Height  Width   Height  Width   Height  Width   Height  Top Left    Bottom  Right
0   256 256 38.2185 38.2185 1048576 1048576 40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 76.437  76.437  524288  524288  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 152.874 152.874 262144  262144  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 305.748 305.748 131072  131072  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 611.496 611.496 65536   65536   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 1222.99 1222.99 32768   32768   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 2445.98 2445.98 16384   16384   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 4891.97 4891.97 8192    8192    40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 9783.94 9783.94 4096    4096    40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 19567.9 19567.9 2048    2048    40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 39135.8 39135.8 1024    1024    40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 78271.5 78271.5 512 512 40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 156543  156543  256 256 40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 313086  313086  128 128 40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 626172  626172  64  64  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 1.25234e+06 1.25234e+06 32  32  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 2.50469e+06 2.50469e+06 16  16  40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 5.00938e+06 5.00938e+06 8   8   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 1.00188e+07 1.00188e+07 4   4   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 2.00375e+07 2.00375e+07 2   2   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
0   256 256 4.0075e+07  4.0075e+07  1   1   40075016.685578 40075016.685578 20037508.342789 -20037508.342789    20037508.342789 20037508.342789
Cache stats
Property    Value
Hits    0
Misses  0
Errors  0

Coordinate Reference System (CRS)
Name    EPSG:3857 - WGS 84 / Pseudo-Mercator
Units   meters
Method  Mercator
Celestial body  Earth
Accuracy    Based on World Geodetic System 1984 ensemble (EPSG:6326), which has a limited accuracy of at best 2 meters.
Reference   Dynamic (relies on a datum which is not plate-fixed)

Identification
Identifier  
Parent Identifier   
Title   
Type    dataset
Language    
Abstract    
Categories  
Keywords    

Extent
CRS 
Spatial Extent  
Temporal Extent 

Access
Fees    
Licenses    
Rights  
Constraints 

Bands
Band count  1

Number  Band    No-Data Min Max
1   Band 1  n/a n/a n/a

Contacts
No contact yet.

References
No links yet.

History
No history yet.
AlisterH commented 1 year ago

Further testing indicates it is related to OTF reprojection.

The crash occurs if the project CRS is a local coordinate system like EPSG:2105

It does not crash if I set the project CRS to match the layer that otherwise causes it to crash. (Interestingly the layer doesn't actually have any visual effect on the Global Map Shading - whereas there is an obvious effect if a normal RGB aerial photo is set as an "elevation surface").

AlisterH commented 1 year ago

Here is a file to give you some sensible extents if you want to test in EPSG:2105 extent.zip

AlisterH commented 1 year ago

I note that if I create a geotif DEM in EPSG:3857, it does not cause a crash (and it does have the expected visual effect on the Global Map Shading)

AlisterH commented 1 year ago

I get the same crash with this layer (which is in EPSG:2193) if the project CRS is set to EPSG:2105

General
Name    Aerial Imagery Basemap
URL https://basemaps.linz.govt.nz/v1/tiles/aerial/NZTM2000Quad/WMTSCapabilities.xml?api=c01gvy0wzeedadwsnrsqa4qty81
Source  contextualWMSLegend=0&crs=EPSG:2193&dpiMode=7&featureCount=10&format=image/webp&layers=aerial&styles=default&tileMatrixSet=NZTM2000Quad&tilePixelRatio=0&url=https://basemaps.linz.govt.nz/v1/tiles/aerial/NZTM2000Quad/WMTSCapabilities.xml?api%3Dc01gvy0wzeedadwsnrsqa4qty81
Provider    wms

Information from provider
Extent  -3260586.7283999999053776,419435.9937999999965541 : 6758167.4429999999701977,10438190.1652000006288290
Width   n/a
Height  n/a
Data type   Could not determine raster data type.
WMS Info    
 Tile Layer Properties  Cache Stats 
Server Properties
Property    Value
WMS Version 1.0.0
Title   LINZ Basemaps Service
Abstract    National map tile service provided by Land Information New Zealand
Keywords    
Online Resource -
Contact Person  LINZ Customer Support
Customer Support
Fees    There are no fees associated with access via the web interface or API.
Access Constraints  Basemap @ CC BY 4.0 Land Information New Zealand
GetCapabilitiesUrl  https://basemaps.linz.govt.nz/v1/tiles/aerial/NZTM2000Quad/WMTSCapabilities.xml?api=c01gvy0wzeedadwsnrsqa4qty81
GetMapUrl   https://basemaps.linz.govt.nz/v1/tiles/aerial/NZTM2000Quad/WMTSCapabilities.xml?api=c01gvy0wzeedadwsnrsqa4qty81
GetFeatureInfoUrl   https://basemaps.linz.govt.nz/v1/tiles/aerial/NZTM2000Quad/WMTSCapabilities.xml?api=c01gvy0wzeedadwsnrsqa4qty81
GetLegendGraphic    
Tile Layer Count    1
GetTileUrl  
Tile templates  image/jpeg:https://basemaps.linz.govt.nz/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.jpeg?api=c01gvy0wzeedadwsnrsqa4qty81
image/png:https://basemaps.linz.govt.nz/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png?api=c01gvy0wzeedadwsnrsqa4qty81
image/webp:https://basemaps.linz.govt.nz/v1/tiles/aerial/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.webp?api=c01gvy0wzeedadwsnrsqa4qty81
FeatureInfo templates   
Identify Formats    
Tileset Properties
Identifier  Tile mode
aerial  WMTS
Property    Value
Title   Aerial Imagery Basemap
Abstract    
Selected    Yes
Available Styles    default
CRS 
CRS Bounding Box
CRS:84  -180.0000000000000000,-49.9298550000000034 : 180.0000000000000000,2.9386030000000001
EPSG:2193   -3260586.7283999999053776,419435.9937999999965541 : 6758167.4429999999701977,10438190.1652000006288290
Available Tilesets  NZTM2000Quad
Selected tile matrix set NZTM2000Quad
Scale   Tile size [px]  Tile size [mu]  Matrix size Matrix extent [mu]  Bounds
Width   Height  Width   Height  Width   Height  Width   Height  Top Left    Bottom  Right
66.6478 256 256 4.77731 4.77731 2097152 2097152 10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
133.296 256 256 9.55463 9.55463 1048576 1048576 10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
266.591 256 256 19.1093 19.1093 524288  524288  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
533.182 256 256 38.2185 38.2185 262144  262144  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
1066.36 256 256 76.437  76.437  131072  131072  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
2132.73 256 256 152.874 152.874 65536   65536   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
4265.46 256 256 305.748 305.748 32768   32768   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
8530.92 256 256 611.496 611.496 16384   16384   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
17061.8 256 256 1222.99 1222.99 8192    8192    10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
34123.7 256 256 2445.98 2445.98 4096    4096    10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
68247.3 256 256 4891.97 4891.97 2048    2048    10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
136495  256 256 9783.94 9783.94 1024    1024    10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
272989  256 256 19567.9 19567.9 512 512 10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
545979  256 256 39135.8 39135.8 256 256 10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
1.09196e+06 256 256 78271.5 78271.5 128 128 10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
2.18392e+06 256 256 156543  156543  64  64  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
4.36783e+06 256 256 313086  313086  32  32  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
8.73566e+06 256 256 626172  626172  16  16  10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
1.74713e+07 256 256 1.25234e+06 1.25234e+06 8   8   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
3.49426e+07 256 256 2.50469e+06 2.50469e+06 4   4   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
6.98853e+07 256 256 5.00938e+06 5.00938e+06 2   2   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
1.39771e+08 256 256 1.00188e+07 1.00188e+07 1   1   10018754.171395 10018754.171395 10438190.165200 -3260586.728400 10438190.165200 6758167.442995
Cache stats
Property    Value
Hits    0
Misses  0
Errors  0

Coordinate Reference System (CRS)
Name    EPSG:2193 - NZGD2000 / New Zealand Transverse Mercator 2000
Units   meters
Method  Transverse Mercator
Celestial body  Earth
Reference   Static (relies on a datum which is plate-fixed)

Identification
Identifier  
Parent Identifier   
Title   
Type    
Language    
Abstract    
Categories  
Keywords    

Extent
CRS 
Spatial Extent  CRS: - Projected
X Minimum: 0
Y Minimum: 0
X Maximum: 0
Y Maximum: 0
Temporal Extent Start: 
End:

Access
Fees    
Licenses    
Rights  
Constraints 

Bands
Band count  1

Number  Band    No-Data Min Max
1   Band 1  n/a n/a n/a

Contacts
ID  Name    Position    Organization    Role    Email   Voice   Fax Addresses
1                               

References
No links yet.

History
No history yet.
AlisterH commented 1 year ago

I also get the same crash with the wmts layers in EPSG:3857 if the project CRS is EPSG:2193

vcloarec commented 1 year ago

I confirm the crash, and it should be fix by #53200 . Just a comment, I am not sure it make sense to activate the elevation for such layer, they do not have elevation values.

AlisterH commented 1 year ago

Yes, it doesn't make sense, but it was possible...

vcloarec commented 1 year ago

@AlisterH , I agree possible and leads to a crash, so not good... my comments to be sure you not waiting for a global shading from these layers.