-
-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App using terrain (raster-dem) crashes when zooming out after zooming in quickly #3982
Comments
Cannot read properties of undefined
when zooming out after zooming in quickly
I can't reproduce this when using the example page on a macos with chrome: Can you try and create a jsbin that reproduces this? |
Hey @harel, I'll investigate further on the first error ( However, for the demo crashing, did you try a non-demo terrain url? I was able to reproduce the error using maplibre.org/maplibre-gl-js/docs/examples/3d-terrain, as long as I used maptiler's tiles. Or just update Here's a 15s video that is 2x speed of me just zooming in and out, and eventually the app crashes. So it took about 30 seconds, less problematic that the original error. 30-2x.mp4I've also attached the html file, just update index.html<!DOCTYPE html>
<html lang="en">
<head>
<title>3D Terrain</title>
<meta property="og:description" content="Go beyond hillshade and show elevation in actual 3D." />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@4.1.2/dist/maplibre-gl.css' />
<script src='https://unpkg.com/maplibre-gl@4.1.2/dist/maplibre-gl.js'></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const key = "MY_KEY_FROM_MAPTILER"
const map = (window.map = new maplibregl.Map({
container: 'map',
zoom: 12,
center: [11.39085, 47.27574],
pitch: 52,
hash: true,
style: {
version: 8,
sources: {
osm: {
type: 'raster',
tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],
tileSize: 256,
attribution: '© OpenStreetMap Contributors',
maxzoom: 19
},
// Use a different source for terrain and hillshade layers, to improve render quality
terrainSource: {
type: 'raster-dem',
url: `https://api.maptiler.com/tiles/terrain-rgb/tiles.json?key=${key}`,
tileSize: 256
},
hillshadeSource: {
type: 'raster-dem',
url: `https://api.maptiler.com/tiles/terrain-rgb/tiles.json?key=${key}`,
tileSize: 256
}
},
layers: [
{
id: 'osm',
type: 'raster',
source: 'osm'
},
{
id: 'hills',
type: 'hillshade',
source: 'hillshadeSource',
layout: {visibility: 'visible'},
paint: {'hillshade-shadow-color': '#473B24'}
}
],
terrain: {
source: 'terrainSource',
exaggeration: 1
}
},
maxZoom: 18,
maxPitch: 85
}));
map.addControl(
new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
})
);
map.addControl(
new maplibregl.TerrainControl({
source: 'terrainSource',
exaggeration: 1
})
);
</script>
</body>
</html> |
The error in the console seems related to matrix inversion if I understand correctly. |
maplibre-gl-js version: 4.1.2
browser:
Overview
I've got an app that uses terrain (raster-dem) as following https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/, but it consistently crashes when zooming out after zooming in quickly. It has different errors depending on the browser.
On Firefox, crashes with
On Chrome, crashes with:
I tried to create a reproducible example with example in https://maplibre.org/maplibre-gl-js/docs/examples/3d-terrain/, but I found a slightly different issue. I just created an
index.html
containing the HTML snippet, and replaced theurl
forterrainSource
andhillshadeSource
withhttps://api.maptiler.com/tiles/terrain-rgb/tiles.json?key=MY_KEY_FROM_MAPTILER
. Zooming in/out in that one will crash with:Steps to Trigger Behavior
There are other ways to reproduce this, like programmatically setting the view state to a high zoom, and them zooming out. But the simplest
It seems like zooming in quickly, or programmatically will be too quick for maplibre to download all the terrain data. It then crashes when zooming out, and can't find it.
Link to Demonstration
Just zoom in and out quickly on https://geojsons.com/. Commenting out https://github.com/ben-xD/geojsons/blob/6f13536abb8e52beb9bded1095501cefc4d13220/frontend/src/map/GeojsonsMap.tsx#L352-L358 will fix the crashing. It seems like using
raster-dem
/ terrain causes this issue.Expected Behavior
No crashing. Zoom in/out works.
Actual Behavior
App crashes when zooming out.
if anyone could suggest a workaround or a fix, I would be grateful. Thanks
Workaround
Disable terrain completely.
The text was updated successfully, but these errors were encountered: