Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't cache server requested glyphs in the local glyph ranges #8657

Merged
merged 5 commits into from
Aug 20, 2019

Conversation

asheemmamoowala
Copy link
Contributor

Fixes #8653.

Font glyphs from the server are requested in packed in ranges of 256 characters. In some rare cases a single range may contain characters that can be locally generated (using tinySDF) and that need to be fetched from the server.

The issue described in #8653 stems from a character from such an overlapping range causing the remote glyphs being cached for even those characters that should be locally generated. This would be a non-issue if both local generation and the server request were resolving to the same font.

The fix is to check each character in the fetched range and skip it if it is should be generated locally. An additional improvement in this PR is to cache the locally generated glyphs so that subsequent tiles don't need to re-generate them.

I also found a bug in Map#setStyle while debugging this issue that uses the wrong default font family for local glyph generation. It should use the value resolved in the map constructor.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team
  • tagged @mapbox/gl-native for native port

cc @chloekraw @tmpsantos

@asheemmamoowala asheemmamoowala added this to the release-queso milestone Aug 19, 2019
@asheemmamoowala asheemmamoowala self-assigned this Aug 19, 2019
@@ -64,6 +64,7 @@ class GlyphManager {

glyph = this._tinySDF(entry, stack, id);
if (glyph) {
entry.glyphs[id] = glyph;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this line change? Were we previously not caching generated glyphs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were we previously not caching generated glyphs?

That's right. Locally generated glyphs were not being cached before this PR in gl-js. Native was already doing it correctly. I considered creating a separate stack for local fonts - so that each local font would only have one cache entry. The current approach can lead to one entry per font stack (in the style definition), but is already an improvement over re-generating each local glyph per tile. Those changes could probably be addressed in a separate PR.

@asheemmamoowala asheemmamoowala merged commit 97ba78b into master Aug 20, 2019
@asheemmamoowala asheemmamoowala deleted the fix-local-glyphs branch August 20, 2019 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Locally generated glyphs shift on over-zoomed tiles
2 participants