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

[core] Don't overwrite locally renderable glyphs with remote glyphs #15407

Merged
merged 4 commits into from
Aug 21, 2019

Conversation

asheemmamoowala
Copy link
Contributor

@asheemmamoowala asheemmamoowala commented Aug 19, 2019

Fixes #15405

TODO

  • Unit tests
  • Manual test to verify the fix

cc @chloekraw @tmpsantos

@asheemmamoowala asheemmamoowala added the Core The cross-platform C++ core, aka mbgl label Aug 19, 2019
@asheemmamoowala asheemmamoowala added this to the release-queso milestone Aug 19, 2019
@alexshalamov alexshalamov changed the title Don't overwrite locally renderable glyphs with remote glyphs [core] Don't overwrite locally renderable glyphs with remote glyphs Aug 20, 2019
@@ -99,8 +99,10 @@ void GlyphManager::processResponse(const Response& res, const FontStack& fontSta

for (auto& glyph : glyphs) {
auto id = glyph.id;
entry.glyphs.erase(id);
entry.glyphs.emplace(id, makeMutable<Glyph>(std::move(glyph)));
if (!localGlyphRasterizer->canRasterizeGlyph(fontStack, id)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have similar check inside GlyphManager::getGlyphs(), so that we request only the ranges that cannot be rasterized locally. How would it be possible to have locally rasterizable glyphs in the response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a few cases where the 256 glyph range includes glyphs that are locally rasterizable and remotely fetched.

In such a range, when a glyph is fetched from the remote request, processResponse will currently add it to the entries table.

A subsequent call to getGlyphs will correctly pass the canRasterizeGlyph check, but will return the glyph that was previously written into entries by processResponse.

if (localGlyphRasterizer->canRasterizeGlyph(fontStack, glyphID)) {
if (entry.glyphs.find(glyphID) == entry.glyphs.end()) {
entry.glyphs.emplace(glyphID, makeMutable<Glyph>(generateLocalSDF(fontStack, glyphID)));
}

@friedbunny friedbunny added the needs changelog Indicates PR needs a changelog entry prior to merging. label Aug 20, 2019
@@ -253,6 +253,57 @@ TEST(GlyphManager, LoadLocalCJKGlyph) {
});
}

TEST(GlyphManager, LoadLocalCJKGlyphAfterLoadingRangeFromURL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pozdnyakov I've added a unit test that reproduces the issue. The fixture is pretty large - but I haven't got an idea of how to create a more synthetic fixture for this test.

It requests 々(0x3005), which is in the range 12244-12543. This range overlaps with Katakana letters which are expected to be locally generated. Without the changes in GlyphManager, this test will use the glyph fetched for the pbf for the katakana letter - and fails.

@asheemmamoowala
Copy link
Contributor Author

Ive as yet been unable to reproduce this issue on the macosapp, mbgl-glfw and on Android. The streets-v11 style doesn't show the behavior shown in #15405, so the fix here is speculative, though the unit test does show there is an underlying issue that is worth fixing.

@asheemmamoowala
Copy link
Contributor Author

asheemmamoowala commented Aug 21, 2019

CI Failures:

  • ci/circleci: ios-debug-xcode11 : is also failing on master. Will need to rebase after a fix is merged there.
  • ci/circleci: android-debug-arm-v8 : Sailfish OS error, but I'm unable to access the logs of that device
  • ci/circleci: linux-render-tests : Failing the regressions/mapbox-gl-js#3107 test which is entirely unrelated to the changes in this PR. (resolved by rebuild)

cc @pozdnyakov @julianrex @LukasPaczos

@asheemmamoowala
Copy link
Contributor Author

asheemmamoowala commented Aug 21, 2019

Changelog:

@chloekraw
Copy link
Contributor

Thanks @asheemmamoowala! I have a preference for the following changelog, any objections?

Reasons:

  • tying this to localIdeographFontFamily increases clarity for the customer about how they could encounter the bug
  • shifting baseline is a side effect of shifting fonts (and not capturing glyph metrics in our renderer); the main problem is the font changes
  • changelogs on native (are supposed to) use the past tense

@asheemmamoowala
Copy link
Contributor Author

asheemmamoowala commented Aug 21, 2019

@chloekraw The platform teams will need to change the final message to reflect the platform version of localIdeographFontFamily, and that is why I was more generic in the description.

GL-Native doesn't use localIdeographFontFamily: true that flag is from GL-JS, so I've edited my original proposal (#15407 (comment)) to reflect your suggestions and the correct option

@chloekraw
Copy link
Contributor

@asheemmamoowala yeah, we always take that step to translate property names to the proper ones on each platform when doing every release. It doesn’t stop us from referencing specific properties in our changelogs.

Also, localIdeographFontFamily: true happens to be accurate for Android.

Copy link
Contributor

@pozdnyakov pozdnyakov left a comment

Choose a reason for hiding this comment

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

@asheemmamoowala thanks for the explanation and the unit test!

@alexshalamov
Copy link
Contributor

@pozdnyakov testTileSetFromTileURLTemplates failure is unrelated to this PR, should we add changelog and land it?

@asheemmamoowala asheemmamoowala requested a review from a team August 21, 2019 08:28
@pozdnyakov pozdnyakov removed the needs changelog Indicates PR needs a changelog entry prior to merging. label Aug 21, 2019
@pozdnyakov pozdnyakov merged commit 4767b56 into master Aug 21, 2019
@pozdnyakov pozdnyakov deleted the fix-local-glyphs branch August 21, 2019 09:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Locally generated glyphs shift on over-zoomed tiles
5 participants