-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fixes #67: cancel unnecessary tile fetches #76
Conversation
An alternative, enhanced approach to this that occurred to me is making a |
Cool! Any reason why tiles and non-tiles have a different API? |
For the webgl version we also fetch a couple tiles at much lower zoom levels ,so that when panning and zooming it can really overscale those tiles instead of showing a blank areas. That wouldn't work with this approach to cancelling requests. That shouldn't block merging this improvement, but something to keep in mind for later. |
This seems to cancel tile download request based on the latest zoom level. However, we actually now when we can cancel a tile load, there is a This would save us from future issues where we'd download tiles of other zoom levels that get cancelled by this magic algorithm, like @ansis described. |
Yeah @ansis @kkaefer this is my main concern with the naivety of this approach (as well as with #74), and I was aware of the parsing abort already. Something along the lines of the future idiom you mention does sound good, so I'll spend some time working on that before we consider a merge here. It does make sense to push this down to the core rather than the platform if possible cleanly. |
Ok, have a look at things now. This is all pushed down to the renderer level and happily, it is already managing
|
Quick look at this @kkaefer? I'd like to merge tomorrow. |
This is working great in all of my testing. In fact, I keep merging it into my testing branches because the performance is much better. |
fixes #67: cancel unnecessary tile fetches
Reason I didn't merge this yet is that linux support is still missing. I'm working on it and try to get it merged today or tomorrow. |
oh, btw, it definitely works a lot better. Great job on the background URL fetches 👍 |
This addresses performance problems caused by waiting for tile fetches to complete even when the tiles will be discarded due to no longer being on screen. We currently discard the tiles, but not until after their network calls have played out.
The approach here is to cancel in-progress tile fetches for zoom levels not equal to the latest requested tile zoom.
NSURLConnection
with iOS 7 / OS X 10.9's newNSURLSession
. This provides for cancelable, asynchronous, block-based network fetches without external dependencies, custom networking classes, or the complicated use of the delegate pattern in C++.platform::request_http_tile()
which adds a tile object pointer argument. This allows the platform-specific code to inspectTile::ID
to get the zoom in question, as opposed to only being privy to the requested URL string. This avoids the need to know/guess that a tile resource is indeed what is requested or to parse its URL string to determine the zoom.background_function()
norforeground_callback()
arguments in the event of a tile cancellation in order to avoid tile error messages / potential complication with future tile 404 fallback mask level #74 fallback fetching due toHTTP 404
.NSURLSession
's ability to query all pending tasks from a singleton./cc @springmeyer who helped me a bit with the tile object pointer argument solution.
Before video: https://dl.dropboxusercontent.com/u/575564/before_cancel.mov
After video: https://dl.dropboxusercontent.com/u/575564/after_cancel.mov
Gist of nearly 400 tile downloads in 30 seconds that were cancelled from second video run: https://gist.github.com/incanus/bc9fd387707b27efe289