domlysz / BlenderGIS

Blender addons to make the bridge between Blender and geographic data
GNU General Public License v3.0
7.78k stars 1.35k forks source link

Crash basemap using GDAL or PIL as image processing engine #671

Open Failxxx opened 2 years ago

Failxxx commented 2 years ago

Blender and OS versions

Blender: version: 3.0.1, branch: master, commit date: 2022-01-25 17:19, hash: dc2d18018171, type: release

DEBUG:BlenderGIS.core.checkdeps:GDAL Python binding available
DEBUG:BlenderGIS.core.checkdeps:PyProj available
DEBUG:BlenderGIS.core.checkdeps:Pillow available
DEBUG:BlenderGIS.core.checkdeps:ImageIO Freeimage plugin available

OS: Ubuntu 18.04.6 LTS

Describe the bug

When I try to use the basemap tool with the following settings (see screenshot) Blender crashes. basemap_config_1

I obtain quite the same result when I try to use it with the the following settings: basemap_config_2

How to Reproduce

Error message

Read prefs: /home/hnum/.config/blender/3.0/config/userpref.blend
Registered Toolsbox OpenFOAM/TELEMAC
DEBUG:BlenderGIS.core.checkdeps:GDAL Python binding available
DEBUG:BlenderGIS.core.checkdeps:PyProj available
DEBUG:BlenderGIS.core.checkdeps:Pillow available
DEBUG:BlenderGIS.core.checkdeps:ImageIO Freeimage plugin available
0  meshes freed
DEBUG:BlenderGIS.operators.view3d_mapviewer:Bounding box request : (-3541550.390625, -1998541.9921875, 3541550.390625, 1998541.9921875)
DEBUG:BlenderGIS.core.basemaps.mapservice:32 tiles requested, 0 already in cache, 32 remains to download
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480) encountered.
DEBUG:BlenderGIS.operators.lib.osm.nominatim:Nominatim search request : https://nominatim.openstreetmap.org/search?format=json&q=Paris&limit=10
DEBUG:BlenderGIS.operators.view3d_mapviewer:Nominatim search results : ['Paris, Île-de-France, France métropolitaine, France', 'Paris, Île-de-France, France métropolitaine, 75000, France', 'Paris, Île-de-France, France métropolitaine, France', 'Paris, Lamar County, Texas, 75460, United States', 'Paris, Bourbon County, Kentucky, United States', 'Paris, Île-de-France, France métropolitaine, France', 'Paris, Henry County, Tennessee, 38242, United States', 'Paris, Henry County, Tennessee, 38242, United States', 'Paris, Edgar County, Illinois, 61944, United States', 'Paris, Edgar County, Illinois, 61944, United States']
DEBUG:BlenderGIS.operators.view3d_mapviewer:Bounding box request : (-2891438.716692187, 4863767.699664076, 4191662.064557813, 8860851.684039075)
DEBUG:BlenderGIS.core.basemaps.mapservice:28 tiles requested, 1 already in cache, 27 remains to download
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480) encountered.
DEBUG:BlenderGIS.operators.view3d_mapviewer:Bounding box request : (-1109498.4852468746, 5855223.170367201, 2432051.9053781256, 7853765.162554701)
DEBUG:BlenderGIS.core.basemaps.mapservice:40 tiles requested, 0 already in cache, 40 remains to download
DEBUG:BlenderGIS.core.basemaps.mapservice:6 tiles requested, 4 already in cache, 2 remains to download
DEBUG:BlenderGIS.core.basemaps.mapservice:http://mt0.google.com/vt/lyrs=s&x=33&y=22&z=6
DEBUG:BlenderGIS.core.basemaps.mapservice:http://mt0.google.com/vt/lyrs=s&x=33&y=21&z=6
DEBUG:BlenderGIS.core.basemaps.mapservice:6 tiles requested, 3 already in cache, 3 remains to download
DEBUG:BlenderGIS.core.basemaps.mapservice:http://mt0.google.com/vt/lyrs=s&x=33&y=22&z=6
DEBUG:BlenderGIS.core.basemaps.mapservice:6 tiles requested, 6 already in cache, 0 remains to download
DEBUG:BlenderGIS.core.basemaps.mapservice:http://mt0.google.com/vt/lyrs=s&x=33&y=23&z=6
DEBUG:BlenderGIS.core.basemaps.mapservice:http://mt0.google.com/vt/lyrs=s&x=33&y=24&z=6
DEBUG:BlenderGIS.core.basemaps.mapservice:0 tiles requested, 0 already in cache, 0 remains to download
Writing: /tmp/blender.crash.txt
Writing: /tmp/blender.crash.txt
Erreur de segmentation (core dumped)

Crash report: blender.crash_2.txt

Failxxx commented 2 years ago

I am facing the same issue as for the second case described in my first post when I use basemap with ESRI / LB93.

Crash report: Logs.txt blender.crash.txt

Failxxx commented 2 years ago

From what I understand, it seems it always come from gdal.Open(vsipath). I tried to replicate the issue in a small separate script but I can't.

My script:

from osgeo import gdal
import random
import ast

def test_function(data):
    vsipath = '/vsimem/' + ''.join(random.choice('abcdefghijklmnopqrstuvwxyz') for i in range(5))
    gdal.FileFromMemBuffer(vsipath, data)
    ds = gdal.Open(vsipath)
    gdal.Unlink(vsipath)
    print("DS:", ds)

for data_path in ["./data_vsimem_a.txt", "./data_vsimem_b.txt"]:
    file = open(data_path, "r")
    data = file.read()[:-1]
    file.close()
    data = ast.literal_eval(data)
    test_function(data)

This script outputs:

DS: <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7f28f0258ea0> >
DS: <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7f28f0258f90> >

So it seems to be working.

Data (samples taken before Blender crashes): data_vsimem_a.txt data_vsimem_b.txt

Failxxx commented 2 years ago

I am facing the same issue using PIL as the image processing engine. Crash report: Logs.txt blender.crash.txt

But good news: it works using ImageIO. So I can finally use basemap with GDAL/ImageIO when using 'Fr Lambert 93' CRS.