maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

Exception in dem_data.ts/backfillBorder

Open cns-solutions-admin opened this issue 1 year ago • 8 comments

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

  1. configure map with terrain on and initial bounds that include a non-existing tile (?)
  2. open map
  3. logs error "dem dimension mismatch" and no map is drawn
  4. drag the map area
  5. 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.

cns-solutions-admin avatar Aug 26 '22 08:08 cns-solutions-admin

If you need help understanding the issue I suggest sharing the problematic code, otherwise you're on your own...

HarelM avatar Aug 26 '22 11:08 HarelM

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

acalcutt avatar Aug 26 '22 12:08 acalcutt

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? 1b (second half) 2

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.

acalcutt avatar Aug 26 '22 14:08 acalcutt

After some more analysis with a simple test page:

  1. 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
  2. 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
  3. 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?

cns-solutions-admin avatar Aug 29 '22 09:08 cns-solutions-admin

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

cns-solutions-admin avatar Aug 29 '22 11:08 cns-solutions-admin

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 :-)

HarelM avatar Aug 29 '22 11:08 HarelM

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.

cns-solutions-admin avatar Aug 30 '22 15:08 cns-solutions-admin

I'm not sure I understand if this is still an issue or not. Please provide a way to reproduce the issue.

HarelM avatar Nov 19 '23 16:11 HarelM