Open nnhubbard opened 3 years ago
I am able to reproduce the crash on iOS and I have a branch at roblabs/maplibre-gl-native:100-updating-local-mbtiles-file-causes-crash that has this sample code for reproducibility and a brute force, but working, fix.
Exception is unhandled due to the local MBTiles file being updated before it was closed properly. Use case will affect any app that uses MBTiles AND updates the same map that is being displayed.
Next Steps:
The crash is due to a thrown exception because an SQL error code came through that is not SQLITE_OK
This throws because the error code that came through is: (6922) SQLITE_IOERR_VNODE
2021-06-28 15:07:55.391756-0700 MapLibre GL[4015:2042647] [DEBUG] {com.mapbox.mbgl.MaptilerFileSou}[Database](6922): statement aborts at 23: [SELECT tile_data FROM tiles where zoom_level = 2 AND tile_column = 1 AND tile_row = 2] disk I/O error
Error code 6922 details:
(6922)
SQLITE_IOERR_VNODE
The SQLITE_IOERR_VNODE error code is a code reserved for use by extensions. It is not used by the SQLite core.
Source: SQLite Result and Error Codes
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
I also get exceptions with mbtiles files. Errors are like this, but only occur (as far as I have observed) when debugging (run app via XCode), they do not happen when I open the app on the device:
[logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: <unresolvable path>
[logging] invalidated open fd: 9 (0x11)
libc++abi: terminating with uncaught exception of type mapbox::sqlite::Exception
terminating with uncaught exception of type mapbox::sqlite::Exception
I am using the
mbtiles://
local file feature and I am running into an issue. In my app, I allow downloading of world-wide maps inmbtiles
format. Updated maps are generated on my server, so users can choose to download an updated map.The crash occurs when user has a specific map loaded, and then they download an updated map of that loaded location and the file on the file system gets replaced. This causes a crash because the database for the
mbtiles
file is not closed before updating the file.Crash:
Replicating Crash:
iosapp
target after usingmake iproj
.mbtiles
file to your project such as from openmaptiles.org.style.json
file to your project such as https://github.com/openmaptiles/maptiler-basic-gl-stylembtiles
path into the style. Update theMBXViewController.m
file of the Demo app with the following:MBXViewController.m add:
MBXViewController.m in
viewDidLoad
around line 279 add:Run the test app
Browse the file system for the
MapLibre GL.app
and view the contents of the app to find yourmbtiles
file. Make a duplicate somewhere and then overwrite the original file within theMapLibre GL.app
folder.Moving the map in the test app will now cause a crash.