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

Adjusting ambient cache size does not work if the SDK's offline functionality is used #15025

Closed
chloekraw opened this issue Jun 28, 2019 · 4 comments
Labels
Core The cross-platform C++ core, aka mbgl offline

Comments

@chloekraw
Copy link
Contributor

chloekraw commented Jun 28, 2019

With #14925, we added an api in core that allows developers to adjust the size of the ambient cache, as well as to disable the ambient cache by setting size to 0.

A trap for users is rooted in the fact that our ambient and offline cache are part of the same sqlite database, and the cache management apis for the ambient cache do not block offline downloads. This is fine except in the case where a developer intends to set the size of the ambient cache and allow their users to use the offline cache.

Because mapbox-gl-native shares the same table of tiles between both the ambient and offline cache, and offline downloads can subsume space seemingly allocated to the ambient cache, a developer/end user can unknowingly limit the ambient cache size through their offline map downloads. This has been reported in #4411.

Further, we don't provide a mechanism for developers or end users to know the size in MB that their offline downloads will take up in advance, so there's no real way to set the ambient cache size if you use offline downloads in our current implementation (unless you sideload or give your users a set, immutable offline package).

In sum:

  • If you attempt to download an offline region, it'll download regardless of the size those tiles would take up.
  • If you set ambient size to 100 MB and download 200 MB of offline region tiles, you will have no transient tiles for the ambient cache.
  • If you set the ambient cache size to 100 MB and download 90 MB of offline region tiles, your ambient cache size will effectively be 10 MB.

What can we do?

@mapbox/maps-android @mapbox/maps-ios @mapbox/gl-native

@chloekraw chloekraw mentioned this issue Jun 28, 2019
7 tasks
@tobrun tobrun added the Core The cross-platform C++ core, aka mbgl label Jul 9, 2019
@JRWilding
Copy link

I was going to start using the new cache apis soon, my plan was that after an offline map download completes, I'd get the total size of all offline maps and then set the cache to be that size +X Mb for the cache. Caching tiles would temporarily be unavailable between a new offline download taking up those X Mb and it finishing, but that is a small window.

Maybe the set ambient cache size should do this internally, so rather than setting a hard size limit to the db, you're setting a offline data + cache size
Since offline maps don't adhere to the size limit anyway, that would make more sense.

Another concern is that offline tiles download from the same url host which interferes with the user engaging with the map (I think you support 20 simultaneous connections to the same host), so if there are 20 offline downloads taking place already, the tiles for where the user is looking waits until they complete. This is further compounded if prefetching is enabled.

Maybe using a wildcard when storing the tile's url would solve this and allow active use to download tiles from a.tile-server.com and offline downloads from b.tile-server.com, but they are both stored as *.tile-server.com (with reads to db updated to support it)

@kkaefer
Copy link
Member

kkaefer commented Aug 5, 2019

The 20 connection limit isn't per host name (Mapbox GL Native doesn't suffer from the hostname-limits that browsers have), it's a global "concurrent request" limit.

@stale stale bot added the archived Archived because of inactivity label Feb 1, 2020
@stale
Copy link

stale bot commented Feb 1, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Feb 1, 2020
@alexshalamov alexshalamov reopened this Feb 3, 2020
@stale stale bot removed the archived Archived because of inactivity label Feb 3, 2020
@alexshalamov
Copy link
Contributor

Addressed by #15622

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl offline
Projects
None yet
Development

No branches or pull requests

6 participants