Open AAverin opened 2 years ago
@tobrun @1ec5 Is this project maintained at all?
I no longer work on this map SDK or its successor, but I’ll make an observation based on https://github.com/flutter-mapbox-gl/maps/issues/703#issuecomment-961932090:
The problem seems to be that MapboxMap is holding connection to cache.db even when map is no longer displayed on the screen and should have been cleared. Installing offline tiles tries to replace cache.db with a different offline set of tiles and fails with sql error. Same thing doesn't happen on Android, replacing cache.db when app is running works fine.
Make sure you (or Flutter Mapbox GL) aren’t manually touching cache.db while the application is running. The only time you can do that safely is at the very beginning of the process, before anything related to Mapbox GL has initialized. Otherwise, the only safe way to sideload offline packs is to call -[MGLOfflineStorage addContentsOfFile:withCompletionHandler:]
.
/cc @mikelmaron
@1ec5 side-loading and activating offline maps basically replaces cache.db file with a new tiles database and then expectation is that new instance of mapbox will load different tileset. This works good for the first instance of mapbox, but not for the second. And it also works fine on Android.
My theory is that connection to cache.db
is not properly disposed or is leaking.
I have explored all the possible options myself – checked code in this repository, checked for any possible leaks in Flutter implementation and in my codebase and now I am at the stage where I need help from original devs. I have also reproduced the problem with the minimal flutter example to make sure there are no problems I have introduced in my codebase.
I know flutter isn't officially supported, but it only wraps around original SDK not adding much on the top, just calling native methods through.
Some more issues that can be related: mapbox/mapbox-gl-native#16502 mapbox/mapbox-gl-native#13282 mapbox/mapbox-gl-native-ios#486
Steps to reproduce
cache.db
files for Mapbox (offline side-loading)Observe error in logs
Expected behavior
Offline maps are working and correctly displaying data from the database
Actual behavior
On second time screen with map opens database crashes and map doesn't display
Configuration
Mapbox SDK versions: 5.6.0 - 6.4.0 iOS/macOS versions: Any Device/simulator models: Any Xcode version: 13