maplibre-gl-js
maplibre-gl-js copied to clipboard
Exception in dem_data.ts/backfillBorder
The initial loading/drawing of the map fails, because of a "dem dimension mismatch". When debugging I saw that sometimes this.dim = 512, while borderTile.dim = 256. However there is only one .mbtiles dem source created according https://demotiles.maplibre.org/terrain-tiles/ (the tile size is 256, although the pngs are 512x512, like in https://maplibre.org/maplibre-gl-js-docs/example/3d-terrain/)
I first thought this happens, because tileserver-gl returns 204 on missing tiles, but it also happens with mbtileserver, which returns 404. Still, it might have to do with missing tiles?
(After dragging the empty div, where the map should be, the map loads and everything works fine.)
maplibre-gl-js version: 2.3.0
browser: any
Steps to Trigger Behavior
- configure map with terrain on and initial bounds that include a non-existing tile (?)
- open map
- logs error "dem dimension mismatch" and no map is drawn
- drag the map area
- map is drawn
Link to Demonstration
Expected Behavior
Missing tiles are ignored
Actual Behavior
Keeps the map from drawing initially. After some mouse action on the (empty) map area, map starts loading and is drawn.
If you need help understanding the issue I suggest sharing the problematic code, otherwise you're on your own...
I've actually wondered if that "tileSize: 256" in the terrain demotiles should just be removed or changed to 512 before. The demo terrain tiles there I made with rio rgbify should be 512px, if I understand right from this rio rgbify thread
I never noticed it causing an issue like you mention here though
I think this demo meets your description, but it doesn't seem to have an issue https://stackblitz.com/edit/web-platform-yhtksh?file=index.html
However, I remembered when I was testing terrain attribution with the tile source in https://github.com/maplibre/maplibre-gl-js/issues/1513 I was having this really weird issue where the map would blank out at different zoom levels.... I wonder if that is similar. I tried to recreate that here and still experience issue https://stackblitz.com/edit/web-platform-nnbpfy?file=index.html (zoom out five times, then center to terrain region Slovensko and zoom in a few times and the raster disappears. if you keep zooming in it eventually comes back.)
Is this similar to what you are seeing?
(second half)
Edit: looking at you description more this probably isn't the same issue since I don't see that error anywhere. though when i had it originally it was also using a raster of just the 'Slovensko' area, but it centered outside that area where no tiles existed. when I zoomed out to find it I experienced the weird map redraw issue.
After some more analysis with a simple test page:
- using the tiles from the example https://maplibre.org/maplibre-gl-js-docs/example/3d-terrain/: returns 404 not found - respective error messages on console, but no terrain errors
- using tiles from tileserver-gl: returns 204 no content => "Error: Could not load image because of An attempt was made to use an object that is not, or is no longer, usable. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported." in Evented
- using mbtileserver: returns transparent 256x256 tile for missing tile => "Uncaught Error: dem dimension mismatch" in DEMData
Our full application (with tileserver-gl) now also gets error 2 (not sure what changed), but the error here somehow prevents the map from loading (probably something to do with it being a React app).
As 1. works and 3. is clearly a mbtileserver problem (added issue https://github.com/consbio/mbtileserver/issues/154), the question is, if maplibre-gl should handle 204 similar to 404 instead of trying to parse the empty result as JSON or image?
Just found out that tileserver-gl and others intentionally return 204 on tile not found: https://github.com/maptiler/tileserver-gl/issues/46
Thus HTTP result 204 should not even be logged as error, as already requested (but closed as stale) in https://github.com/maplibre/maplibre-gl-js/issues/160
Feel free to revisit this PR and issue (#161). I was under the impression this was merged and fixed, apparently it wasn't. There's a linked PR that wasn't going anywhere where there is a fix apparently. I suggest to open a new one and link to it. I have low expectations it will solve your case, but it wouldn't hurt to try :-)
Created #1579 for HTTP result 204/404 handling.
However, the problem that the map does not load, seems to be unrelated to 204/404 handling. A workaround seems to be to start the map in non-terrain mode and let the user switch to terrain using the control.
I'm not sure I understand if this is still an issue or not. Please provide a way to reproduce the issue.