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

Unify offline and ambient caches - #4377

Merged
1ec5 merged 1 commit into
release-ios-3.2.0-android-4.0.0from
1ec5-offline-unify-cache-4362
Mar 18, 2016
Merged

1ec5 merged 1 commit into
release-ios-3.2.0-android-4.0.0from
1ec5-offline-unify-cache-4362

Conversation

@1ec5

@1ec5 1ec5 commented Mar 18, 2016

Copy link
Copy Markdown
Contributor

Now there’s only one instance of mbgl::OfflineFileSource, created when the shared MGLOfflineStorage object is initialized. Also create and use the shared MGLOfflineStorage object when initializing an MGLMapView object.

The unified cache file is located in a subdirectory of Application Support, where the SDK has control over the file’s lifetime. The subdirectory is already named after the host application’s bundle identifier, ensuring that each Mapbox-powered application has an independent tile limit.

If there’s an ambient cache in a subdirectory of Caches, delete it. If there’s an offline cache in a subdirectory of Documents on iOS or Caches on OS X, move it to the unified cache location in a subdirectory of Application Support.

There are a couple consequences to this approach:

  1. On iOS, it isn’t possible for a user to export their offline cache to another device or import it from another device. The application would have to move the file into Documents first.
  2. If disk space runs low on the iOS device, the unified cache will continue to eat up disk space, potentially due to ambiently cached content, and the only way to reclaim that space would be to delete the application (along with all the offline content). See Add API to clear ambient cache #4376 for a possible solution.
  3. On OS X, it isn’t possible for two Mapbox-powered applications to share an ambient cache. The unified cache’s path must include the application’s bundle identifier, because otherwise one application’s offline packs would count against another application’s limits.

Fixes the iOS/OS X side of #4362.

/cc @jfirebaugh @boundsj

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline labels Mar 18, 2016
@1ec5 1ec5 self-assigned this Mar 18, 2016
@1ec5 1ec5 added this to the ios-v3.2.0 milestone Mar 18, 2016
@1ec5
1ec5 force-pushed the 1ec5-offline-unify-cache-4362 branch from ac014a0 to f06b38b Compare March 18, 2016 20:12
@jfirebaugh

Copy link
Copy Markdown
Contributor

👍

I got tripped up by simulator behavior, but after figuring that out, I can confirm that the migration works and offline packs are used when offline.

There is now only one instance of mbgl::OfflineFileSource, created when the shared MGLOfflineStorage object is initialized. Also create and use the shared MGLOfflineStorage object when initializing an MGLMapView object. The unified cache file is located in a subdirectory of Application Support, where the SDK has control over the file’s lifetime. The subdirectory is already named after the host application’s bundle identifier, ensuring that each Mapbox-powered application has an independent tile limit. If there’s an ambient cache in a subdirectory of Caches, delete it. If there’s an offline cache in a subdirectory of Documents on iOS or Caches on OS X, move it to the unified cache location in a subdirectory of Application Support.

Fixes the iOS/OS X side of #4338.
@1ec5

1ec5 commented Mar 18, 2016

Copy link
Copy Markdown
Contributor Author

Builds are passing; merging now.

@1ec5
1ec5 force-pushed the 1ec5-offline-unify-cache-4362 branch from f06b38b to b493bdc Compare March 18, 2016 21:02
@1ec5
1ec5 merged commit b493bdc into release-ios-3.2.0-android-4.0.0 Mar 18, 2016
@1ec5
1ec5 deleted the 1ec5-offline-unify-cache-4362 branch March 18, 2016 21:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants