Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Closing and reopening offline map breaks map functionality #637

Open
AAverin opened this issue Oct 7, 2021 · 3 comments
Open

Closing and reopening offline map breaks map functionality #637

AAverin opened this issue Oct 7, 2021 · 3 comments

Comments

@AAverin
Copy link

AAverin commented Oct 7, 2021

Steps to reproduce

  1. Have offline map put into cache.db files for Mapbox (offline side-loading)
  2. Open the screen with map while device is offline, observe map working
  3. Close the screen with map
  4. Open the screen with map again, observe map not working
  5. Observe error in logs
[logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/mobile/Containers/Data/Application/E9F89FE6-3545-416A-A344-313E5A65A875/Library/Application Support/___/.mapbox/cache.db

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

@AAverin AAverin changed the title Closing and reopening offline map results in SQL error Closing and reopening offline map breaks map functionality Oct 7, 2021
@AAverin
Copy link
Author

AAverin commented Nov 1, 2021

@tobrun @1ec5 Is this project maintained at all?

@1ec5
Copy link
Contributor

1ec5 commented Jan 31, 2022

I no longer work on this map SDK or its successor, but I’ll make an observation based on flutter-mapbox-gl/maps#703 (comment):

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

@AAverin
Copy link
Author

AAverin commented Jan 31, 2022

@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
#486

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants