Comments (5)
@incanus That sounds good to me. I've been thinking about digging through the WWDC videos and otherwise seeing what sort of best practices there might be around all this stuff since it's not an area I'm particularly familiar with. I did notice some of the built in caching features while digging through the NSURLConnection documentation, and it seems like there's a lot of pretty well developed stuff there we could potentially take advantage of. On my list.
from mbxmapkit.
Some interesting references:
- WWDC 2013 session 705
- http://nshipster.com/nsurlcache/ (including notes about implementation not matching documentation)
- http://stackoverflow.com/questions/21540399/afnetworking-image-cache-does-not-empty-on-memory-warning (system wide memory pressure vs. memory warning for an individual app)
- AFNetworking/AFNetworking#1136 (an extended discussion of disk caching issues related to the unreliability of NSURLCache)
from mbxmapkit.
And Apple's URL Loading System Programming Guide looks worthy of some serious study too.
from mbxmapkit.
From my reading today, it seems like people who attempt to use NSURLCache to meet their needs for persistent offline storage tend to run into problems. However, I get the impression that it does work well for its intended purpose (i.e. act like a cache by improving performance and reducing bandwidth usage).
The core issue seems to be that the semantics of a "cache" and "persistent data store" are very different, but it's tempting to try and lump them together into a single hybrid implementation. NSURLCache can appear to behave like a really handy offline data store, right up until the point that it's called upon to free up space in response to memory pressure.
I'm wondering about possible ways of making a clear distinction between caching for performance and saving map data for offline use. Currently I'm thinking along the lines of:
- Use NSURLCache for performance caching, configuring it with relatively modest default RAM and disk space limits.
- Make an offline map manager class which can use an NSURLSession to download all the tiles and associated JSON for in a particular region and save them to a persistent location on disk (i.e. not in the cache directory). These requests would make use of NSURLCache to implement standard HTTP caching behavior along the lines of #46.
- Configure things so that when
loadTileAtPath:result:
uses NSURLCache to fetch a tile or JSON file, the following sequence is used by NSURLCache to fulfill the request:- First attempt to get the resource from the normal memory cache,
- Next attempt to get the resource from the normal disk cache,
- Next attempt to get the resource from the offline map manager <- this is the critical part ,
- And if all that fails, finally attempt to download the resource by HTTP
An arrangement like what I described sets up the likelihood that, at times, map data will be present in the persistent store and in the cache, but I argue that is totally acceptable. As long as the NSURLCache disk space limit is set to something reasonable, and we refrain from interfering with its normal mechanisms for responding to memory pressure, there shouldn't be any problem.
from mbxmapkit.
NSURLCache is cool, and it works well. I think we should definitely use it for performance caching, and that we should implement a separate tile storage mechanism for persistent offline raster tile layers. See #73 (scroll down a bit)
from mbxmapkit.
Related Issues (20)
- MKOverlayRenderer setNeedsDisplayInMapRect:zoomScale: HOT 6
- [VKTileKeyMap enumerateKeysAndObjectsUsingBlock:] HOT 16
- how to grant app to use my api access token? HOT 1
- React Native Module HOT 1
- BSD license HOT 4
- warning in new Xcode on canReplaceMapContent
- mbx_zoomLevel might return the wrong zoom level
- MBXMapKitErrorCodeOfflineMapSqlite to delegate
- MBXMapKit Example App high CPU usage HOT 7
- Crashes in [VKRasterOverlayTileSource invalidateRect:level:] and [VKTileKeyMap enumerateKeysAndObjectsUsingBlock:] HOT 2
- MBXOfflineMapDownloader suspend/resume sequence and activeDataSessionTasks count HOT 3
- Redundant tile loads in MBXRasterTileRenderer canDrawMapRect: when using 512px tiles HOT 6
- Swift: MGLMultiPoint should use Int for pointCount HOT 3
- Remove `example.mapids` and make sure offline works
- deprecate repo in favor of GL HOT 8
- random crashes coming from MBXMapKit/VectorKit HOT 1
- Is 0.8.0 / v4 API backwards compatible? HOT 1
- MapID problem? HOT 1
- Remove mb-pages branch HOT 1
- IOS SDK Cluster effect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mbxmapkit.