maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.42k stars 692 forks source link

Map blurs in response to 404s when terrain is enabled #4692

Open zta6 opened 3 weeks ago

zta6 commented 3 weeks ago

maplibre-gl-js version: 4.3.2, observed in 3.0.0 as well.

browser: Observed in Chrome and Safari

Steps to Trigger Behavior

  1. Display a layer with limited geographic coverage, or a layer that returns 404s intermittently
  2. Turn on terrain
  3. If viewing a layer with limited geographic coverage, navigate to the edge of the layer.
  4. Observe that when the uncovered areas are visible (i.e. 404s are being received) that the rest of the layer blurs in response to those 404s.

A related note: If I set maxTileCacheZoomLevels to 1, or maxTileCacheZoomSize to 0 it seems to make this issue less pronounced. It seems as if the lower resolution tiles that are being loaded in response to 404s are coming from the cache. Restricting/removing the cache results in a smaller degradation of resolution in response to 404s, since there are no low-zoom tiles in the cache to fall back to. At least thats what it seems like to me.

Link to Demonstration

Had to reduce the resolution of this to upload to github so it's a bit hard to see, but if you watch the top left corner of the map you can see the gray 'no coverage' area at around the 5 second mark. Whether or not that no coverage area is in the mapview is what determines whether the mapviewer is blurry or clear.

https://github.com/user-attachments/assets/7bcabb8e-1be6-47c6-ab09-02e32091c791

Expected Behavior

The map responds gracefully to 404s

Actual Behavior

The map's resolution degrades significantly in response to 404s.

HarelM commented 3 weeks ago

Thanks for taking the time to open this issue! Can you check if this ever worked as expected in previous version that contain the terrain feature? Also, can you please create a minimal jsbin/codepen/stackblitz reproduction, preferably with minimum number of layers?

zta6 commented 3 weeks ago

I went back as far as 3.0.0 and as far forward as 4.7.0 and the issue exists in both those version as well as in 4.3.2 which we're using.

I'm not sure how I'd create a demo unless I can find a tile server that returns (some) 404s dependably, or without control over the code on the tile server itself which isn't possible with a demo tileset hosted by someone else.

HarelM commented 3 weeks ago

I think you can use addProtocol to return 404 somehow? Or maybe transformRequest to specific tiles, just for the sake of a small reproduction...?