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

optimize glyph usage for offline #4069

Closed

Description

@jfirebaugh

Currently, the first time an offline region is created for a particular style, we download all glyph ranges for all font stacks in the style. Offline resource sharing ensures that future offline regions with the same style reuse these glyphs.

Downloading only the glyph ranges actually used by visible features in the region would require parsing every downloaded tile, iterating over every feature, extracting the property values that might be rendered as text, and accumulating a set of used glyphs.

That seemed like a non-starter to me both in terms of the processing overhead for the thousands or tens of thousands of tiles in an offline download, and in the complexity it would add to the offline implementation, which was (and is) under severe time pressure.

While I don't see the current strategy changing for changing for v1 of offline, we should consider future optimizations that lower the glyph overhead for the initial region.

Activity

  1. added
    performance
    on Feb 22, 2016
  2. mikemorris commented on Feb 22, 2016

    @mikemorris
    Contributor

    Possible implementations to reduce glyph overhead:

  3. mourner commented on Feb 22, 2016

    @mourner
    Member

    This is probably a throwaway idea but mentioning it anyway: we could add an optional field to the top-level Tile pbf message (or Layer) with a packed array of numbers representing glyph ranges required by that tile. This would require some additional code in mapnik-vector-tile, and would possibly need a minor spec version change to add this field. But there are pros:

    • Adding this info when baking tiles is cheap
    • We'll save a ton of bandwidth on offline glyphs
    • The solution avoids the complexity of using a bbox-based API
    • No additional requests necessary
    • If the field is present, the client can start fetching glyph tiles before we completed parsing the whole vector tile
  4. jfirebaugh commented on Feb 22, 2016

    @jfirebaugh
    ContributorAuthor

    Per chat with @mikemorris and @yhahn, the approach we'd like to take is to give mbgl more smarts about which set of fonts should be considered "fallbacks" (e.g. "Arial Unicode Regular"), and then either ship a set of glyph SDFs for these fallbacks with the SDK, or for cases where shipped SDK/app size is at issue, download and pre-cache this set at runtime.

    Then glyph requests (both offline and online) could be smart about splitting any given fontstack [A, B, ..., F, G] into a prefix of non-cached [A, B, ...] and a suffix of pre-cached [..., F, G] fonts. It would request glyph SDFs for [A, B, ...] at runtime, and composite the result with the cached SDFs for ..., F, G. This "compositing" would be entirely on a glyph SDF level -- no SDF rendering machinery would be required.

  5. brunoabinader commented on Apr 13, 2016

    @brunoabinader
    Contributor

    ship a set of glyph SDFs for these fallbacks with the SDK

    This idea looks great. I believe this could help (1) solving the initial waiting period for labels to appear on places e.g. using CJK characters and (2) greatly reducing bandwidth usage for common data. Do we have numbers of how much space is required for our glyph set?

  6. dpieri commented on Jul 29, 2016

    @dpieri

    Related to this, we've been seeing 404 responses on certain glyph ranges from the Mapbox API. One 404 will kill the offline download, so this issue increases the likelihood that an offline download will fail.

    This font works

    But this one does not.

    Right now our offline downloads are failing 100% of the time because of these font 404s.

    Edit: That font API url is no longer responding with a 404. The larger issue of a single bad font stopping the offline download process still remains.

  7. 1ec5 commented on Aug 2, 2016

    @1ec5
    Contributor

    @dpieri, does the 404 still reproduce for you? We had a server configuration issue recently (related to rate limiting) that perhaps triggered these errors. You're right that errors like this shouldn't bork the download, though.

  8. dpieri commented on Aug 2, 2016

    @dpieri

    @1ec5 I'm not seeing a 404 on that specific resource anymore. In general the download process has been a bit mysterious. Yesterday evening I found that after clearing our app's data and cache (via the Android app settings menu) downloads would fail on 404s regularly unless I proxied through my laptop to figure out what was 404ing. It seems to be working better now, but because of the weird behavior with the proxy I can't tell you which asset was 404ing.

  9. mkv123 commented on Oct 11, 2016

    @mkv123

    Currently downloading an offline region is about 73MB of fonts and then 1MB of actual vector data. Is there a workaround to reduce the static overhead of offline data caused by the fonts?

  10. hhartz commented on Jan 25, 2017

    @hhartz

    Being able to ship these resources alongside the app instead of downloading would significantly improve the user experience for end users, as the initial download in most cases is so slow that users think something is wrong.

  11. added
    Core
    on May 30, 2017
  12. ChrisLoer commented on Apr 3, 2018

    @ChrisLoer
    Contributor

    #11561 proposes the partial solution of allowing offline downloads to exclude CJK glyphs when local CJK glyph generation is supported.

  13. stale commented on Oct 25, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  14. added
    archived
    on Oct 25, 2018
  15. brunoabinader commented on Oct 25, 2018

    @brunoabinader
    Contributor

    I think this idea is worth reconsidering - we might end up saving a lot on the offline cache size!

  16. removed
    archived
    on Oct 25, 2018
  17. added
    archived
    on Apr 23, 2019
  18. stale commented on Apr 23, 2019

    @stale

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

  19. LeeroyDing commented on Apr 24, 2019

    @LeeroyDing

    Is there a workaround for it?

  20. removed
    archived
    on Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Coreofflineperformancetext rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions