mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.16k stars 2.22k forks source link

Some symbols disappear in globe projection between zoom levels 5 and 6 #12645

Open osvodef opened 1 year ago

osvodef commented 1 year ago

mapbox-gl-js version: 2.13.0

browser: Chrome 111

Description

Symbols of these types:

  1. Line labels
  2. Point labels with variable anchors
  3. Symbols with both text-variable-anchor and icon-text-fit set

are not rendered in globe projection between GLOBE_ZOOM_THRESHOLD_MIN and GLOBE_ZOOM_THRESHOLD_MAX.

Steps to Trigger Behavior

  1. Go to https://codepen.io/osvodef/pen/povExxg
  2. Zoom in

Link to Demonstration

https://codepen.io/osvodef/pen/povExxg

Expected Behavior

All labels stay visible while crossing zoom levels 5–6

Actual Behavior

3 labels disappear, 1 stays

Additional info

I did a bit of detective work myself on this issue, hope this helps.

I tracked the bug down to symbol vertex shaders and u_zoom_transition uniform. Forcing its value to 0 makes the labels appear, but on wrong positions on the screen, as if no globe→mercator transition is happening.

In the shaders, I found this line that hides the labels when u_zoom_transition > 0:

#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
    projection_transition_fade = 1.0 - step(EPSILON, u_zoom_transition);
#endif

However, just removing this line doesn’t fix the issue since the screen coordinates calculated by the shader are also wrong when u_zoom_transition > 0, usually putting the symbol completely off-screen.

The projection_transition_fade line suggests that this was done intentionally, however, I couldn’t find any relevant discussion in PRs/issues here so I decided to report it anyway.

mourner commented 1 year ago

@karimnaaji looks like this was introduced in #11015 — maybe you have insight into what's going on here?

tonnoz commented 1 year ago

I have a similar type of issue, for me the symbols don't disappear but the Features do. The problem for me manifest only if zoom >=6. This is my ugly workaround at the moment:


<MapGL
     projection={zoom < 6 ? "globe": "mercator"} //TODO: fix me
     initialViewState={mapSettings.defaults}
     ...
/>      

Edit: it was fixed with an update, now all good!
stepankuzmin commented 1 year ago

Could be related to https://github.com/mapbox/mapbox-gl-js/issues/12100