-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
Yeah this sounds like a good design. Keeping offline and online well separated will reduce complexity and provide flexibility for future enhancements. |
I am currently thinking of having a vector of file sources per above, as well as adding a This may not work out in practice, but I'm going to attempt it first. |
Ok, as of 0e568b2, we have multiple file sources in place and the first (mock offline) one provides local tiles if a) we are requesting tiles and b) they contain It lives! Next up will be hooking up a more concrete MBTiles file source in place of |
I should add that this is more a proof of concept of |
How will an app bundling the style files work with this? E.g. if you want 100% offline map you would need MBTiles of all the vector data, plus locally bundled style JSON, sprites, patterns, fonts etc |
Yeah, working on that. I have some ideas. |
Ok, as of 6acda8c we have a basic hookup to a (raster) MBTiles (see here) as a proof of concept of the idea of multiple file sources and failover between them based on coverage. Next up is to start experimenting with offline vector maps. Tiles are easy, but we need to think about related assets such as sprites, style, glyphs, etc. and if MBTiles is the right way to go there. |
The biggest variable I see here is both quantity of, and determining required assets for, font data for various regions. In some minimal browsing, requests tend to look like this: https://gist.github.com/incanus/c402b7e32ff064028797 Sorting and de-deduping, across 13 zoom levels that's:
|
Font glyphs are turning out to be the real wildcard here. The way we determine which font glyphs need downloaded is:
Anything sound not right about this @mikemorris @kkaefer? /cc @twbell re: possible offline feature restrictions. |
Of course an option here would be to just download all 10 ranges for a given font style upfront (as "0 to 2560" seems to imply that that's all there are, i.e. max 2.5k characters per font). Will do some measurement on relative sizes of glyphs compared to tiles themselves next. |
In that case, you could scan a style upfront for font strings, e.g.
Sourced from Four fonts |
In some basic testing, generally I am seeing glyph assets be about the same, but occasionally more numerous, and about the same, but occasionally larger in size. Basic Asia-focused activity test:
|
Re: #2939 (comment) and just pre-downloading all ranges, @jfirebaugh indicates our docs might not be up to date and:
That's 256 things per font face to download, not 10. So that's just if we wanted to get ahead of possible style changes, but wouldn't be relevant if the fonts/labels stay the same while offline and only drawing properties (colors, strokes, fills, details hidden, etc.) are changed at runtime instead. |
The short of all of this is that it's becoming apparent that fetch-and-store like we did on raster won't suffice for vector, as we will have to also parse vector tiles to find dependent glyphs to download as well. As best I can see so far. That's a bit more overhead, hopefully not tremendous, but does add quite a bit of complexity, particularly if we want to (rightfully, I think) reuse parts of our rendering-based tile parsing infrastructure as it already holds the logic combining vector tiles with applied styling. |
Have you thought about creating an API endpoint to determine glyphs needed for a bbox? |
That's a neat idea @lucaswoj — it'd still need crossed with a style to be efficient, but that's doable. |
An example why: a style might not show POIs, which would greatly reduce the number of strings needing to be parsed and glyph-ranged. Or a style might only use |
Good progress here. One thing that jumps out at me is that a synchronous and blocking I think we'll need to keep the |
Yeah, I naively started with blocking, with the goal of digging into it further. Thanks for the eyeballs @jfirebaugh. |
Doing some tile fetching work over in https://github.com/incanus/TileCacher, which also serves as a good test of delegate render completion callbacks and could be used in future as a benchmarker once we have it hooked up directly to an atomic offline source, since we can measure render time given known local data. |
I updated this to latest |
@incanus Is there any plan to add routing and search to the offline roadmap? Will it be developed in the open like gl native client? Its one big item that's missing from mapbox sdk. |
@mb12 -- ancillary offline services are on our radar; focusing on getting the basics in-play first. |
89874f8
to
d4feaf6
Compare
The architectural changes needed here are:
|
d4feaf6
to
a5f0c0b
Compare
@jfirebaugh Keep in mind here the use case of multiple offline documents, the set of which can differ at runtime. A concrete use case for this is a parks or golf courses app that uses a paywall to give access to individual sections of offline area. At runtime, the dev just wants to pass in the supported documents/regions (or perhaps alter them later as new ones becomes available, or maybe even just say "use all of the downloaded regions"), but does not want to have to reinitialize or reconfigure the map view (perhaps jarringly visually) just to change the attached regions. This would be most evident when the map viewport is made to change to a new region and associated backend configuration / singular referenced file path would have to change in response, possibly delaying actual map rendering as file sources are reconfigured. My original goal here was an API that allows management of a set of You can see a successful model of this in the old MBXMapKit idea of multiple Keep in mind also that while we haven't explicitly promised it, we may also want to allow for arbitrary MBTiles file path hookup (#3053) alongside the internally-managed and SDK-downloaded documents. I think we need a multiple offline file source API for these reasons, and as the evolution of what we've learned through use and feedback of our past offline mobile APIs. With regard to 2x the queries, yes, we could optimize this a bit; however, using the (optional) |
Yes, good to keep those use cases in mind. However, I believe the management of "sets of offline resources" should be handled internally to |
Yep, agree. My read on this was instead of obtaining |
e7ded52
to
8f3d5fa
Compare
cbb6c31
to
765db30
Compare
Build issues are now fixed, down to test failures. |
be04d73
to
920f8e9
Compare
920f8e9
to
1967bd8
Compare
⇢ #3715 |
First movements towards #584.
My current thinking here is to have
ThreadContext
return an array of ordered file sources, not just a lone one with which the map/map context/thread context was created. For example, you'd have an offline source, then theDefaultFileSource
, and a fallback would occur if the offline one didn't have a resource (either by circumstance or design).This should work during e.g.
VectorTileMonitor::monitorTile()
request kickoffs as they query theutil::ThreadContext::getFileSource()
API for each request, so that means the array could be mutated at various points during the lifecycle and such an API could return the latest iteration of the array.Currently working on a basic mockup file source, then some structure to test this design out as the first steps.
I do think we should keep offline sources clear of
DefaultFileSource
and its associated (SQLite-backed) cache complexity.