mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

Mapbox offline tile cache stored under "data" and not as "cache"

Open carstenhag opened this issue 4 years ago • 13 comments

Android API: Android 10 Mapbox Navigation SDK version:

  implementation 'com.mapbox.navigation:ui:1.0.0-rc.7'
  implementation 'com.mapbox.navigation:core:1.1.0-alpha.4'

Steps to trigger behavior

  1. Embed Mapbox Core and UI SDK into app
  2. Use it, launch some navigation stuff, drag the map around, not really sure about the specifics.
  3. Open app storage settings (see screenshot)
Bildschirmfoto 2020-09-26 um 22 33 57

Expected behavior

An user can clean up app storage by using the "clear cache" feature and mapbox related cache files should get deleted. The mapbox cache files are stored as cache files and not as data.

Actual behavior

Mapbox stores tiles data and its sqlite database in the cache files, as the files are not critical and should be deleted first in my opinion. A user that sees an app using 300 MB of storage, without having manually downloaded a map or any big file, will not really like the big size if storage gets low.

The user will then try to delete the cache, but that may only get 5MB of storage back. The 113 MB of mapbox files pertain to the "data" category and can also be deleted, but if the user does so, access tokens, shared prefs, etc will also be deleted which is not desired.

$ du -h /Users/carstenh/Downloads/extractedAppData/files/
 15M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/0/003
 15M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/0
8,8M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/1/049
7,5M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/1/050
 16M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/1
 18M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/797
7,2M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/799
8,5M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/798
5,7M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/805
8,5M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/795
4,5M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/807
5,1M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000/801
 57M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2/000
 57M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles/2
 89M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00/tiles
 89M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com/2020_02_02-03_00_00
 89M	/Users/carstenh/Downloads/extractedAppData/files//Offline/api.mapbox.com
 89M	/Users/carstenh/Downloads/extractedAppData/files//Offline
113M	/Users/carstenh/Downloads/extractedAppData/files/

(mbgl-offline.db taking 25.7MB is included in there)

carstenhag avatar Sep 26 '20 20:09 carstenhag

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 21:12 stale[bot]

Still relevant

carstenhag avatar Dec 25 '20 21:12 carstenhag

cc @mskurydin @etl @kkaefer for visibility

Guardiola31337 avatar Mar 16 '21 19:03 Guardiola31337

сс @brunoabinader

etl avatar Mar 16 '21 20:03 etl

@mr1sunshine is that something we could add/fix in the SystemInformation API?

brunoabinader avatar Mar 17 '21 13:03 brunoabinader

@mr1sunshine is that something we could add/fix in the SystemInformation API?

It seems that we can extend our SystemInformation with an additional path for cache files.

mr1sunshine avatar Mar 17 '21 13:03 mr1sunshine

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 18 '21 23:06 stale[bot]

Still relevant

carstenhag avatar Jun 19 '21 06:06 carstenhag

@carstenhag This will be configurable in version 2 of the Nav SDK, which is currently in beta. The storage location can be controlled by constructing a custom TileStore instance and passing it to the Nav SDK constructor.

However, the default will still be to store tiles as “data” and not ”cache”. The reason for this is that Android (and iOS) reserve the right to delete an app’s cache directory at any time. Users who create offline regions would then be in a situation where they’ve explicitly downloaded an offline region which was deleted automatically by the system, which I’d argue would be the worst case scenario for a navigation app.

kkaefer avatar Jun 21 '21 10:06 kkaefer

Seems like a good solution :).

carstenhag avatar Jun 21 '21 10:06 carstenhag

So I would say if this is documented properly, it could be closed, but I don't know if it is documented. Do you know?

carstenhag avatar Jul 09 '21 13:07 carstenhag

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 29 '22 15:04 stale[bot]

Still relevant I guess. I did not check though. I'm not using mapbox anymore currently.

@kkaefer can you please check?

carstenhag avatar Apr 29 '22 16:04 carstenhag