Skip to content

Performance Issue in updateHeights with High-Resolution Custom Terrain Providers #12476

Closed
@calogeromauceri

Description

@calogeromauceri

What happened?

Summary

When using a high-resolution custom terrain provider (e.g., ArcGIS WorldElevation3D), updateHeights in QuadtreePrimitive struggles to keep up with entity height updates. The intersections with the terrain take significantly longer (often exceeding 50ms), while the time limit for updateHeights is only 2ms.

This results in a growing queue of tilesToUpdateHeights, leading to poor entity positioning and potential performance degradation. The issue does not occur when using Cesium.createWorldTerrainAsync().

Reproduction steps

Sandcastle example

Observations & Debugging

To analyze the issue, I added logging inside updateHeights as follows:

const currentTime = getTimestamp();
const deltaTime = currentTime - startTime; // Calculate elapsed time
if (currentTime >= endTime) {
    console.log(`Time slice exceeded: Δt = ${deltaTime} ms (limit: ${timeSlice} ms)`);
    console.log(`Queue size: tilesToUpdateHeights.length = ${tilesToUpdateHeights.length}`);
    console.log(`Last processed tile index: ${primitive._lastTileIndex}`);
    timeSliceMax = true;
    break;
}

After all tiles have been loaded, I keep seeing these logs:

Time slice exceeded: Δt = 53.59999990463257 ms (limit: 2 ms)
Queue size: tilesToUpdateHeights.length = 56
Last processed tile index: 1
Time slice exceeded: Δt = 86.2999997138977 ms (limit: 2 ms)
Queue size: tilesToUpdateHeights.length = 56
Last processed tile index: 1
...

Key Findings:

  • The intersection time consistently exceeds 50ms, whereas the function is only allowed 2ms per update cycle.
  • This causes tilesToUpdateHeights to grow indefinitely, preventing entity heights from updating.
  • Switching to Cesium.createWorldTerrainAsync() eliminates the issue, suggesting that high-resolution terrain data slows down intersections significantly.

Sandcastle example

https://sandcastle.cesium.com/#c=rVTbbhs3EP2VgdCHla2Qko00vihGDTtNAsSxYSntQ7ZwaO5oRZRLCuSsFNXwv2f2JkuN+5CgxALkkjNnzpwZUnsXCZYGVxjgNThcwQVGUxbij3ovSXu6/r/wjpRxGNJe/zR1qZN7qaOwhofUQQsgokaHgjAENr0JfmmyCrayAFArZahD1wEV4Z8+2GzamJ/HtdNJhf0IWpGeQ8IHPvSbCCvjMr8SymKg5MvvyljMgDxYr3huIAT88lD7PH5pcFK3JyuuP8/zPOi37yfTKtobi0tFxrvprp+YBV98CjZp3AHS3pxoEU+kxM7lMBMq6NxEoX0hm6UMGElGDEvDEstai02Mw0vZhuHV+0LlOGHDSv1BE+b/Fip1O9rk1t+jyHBB8ynTPM/ZK1JLiRuFQol1G8xKpyvCkCPdKg5dXM9mESlp6QSkMjhIrhTNRagN+OgFDMXLPuzxNKzH6BSkhEmhrIXGCnyNw+yqMLruU2QFmM2FCuTzoBZzo5lLW6rt3boml5gHxJgc/SqOD14O4OCVOD46Gg1g2K+jvWnQIJZFYWgriiNDBiNDf/6Lk5z5AIlFAsM7w1OexjCq5v39NsnGz3qXGyozfOJUZ02+Y/IMf/Hktf+9hlV1NvDcGD+O3jn9B/gTfJ31msHbPuhUECrLkoem6RY+mqrYJ9ua80q5wx3FNzkNNqwHcMxl7rfdW/gM7Qk8dFemGmUwJ3x3hJD8TVSxsHipSMnaNsom4pVy7eqOl9ym95sb0Yw5mnxOtzhjLZzGDdN3u/vi4sP51c3d9Pru7e31p4+XOxiFcaYoixvzFe3E/MMgo4OjXQv1tbKYaL5mfDocbp0+1uvHTt2NjosyzpNG5frSbd05Ckr/zS9MV4LO5/Ow6r/eoDeOtLZ41gX5zRQLH4glswmLRchi8XMa5X3JOCR0jE3nAIzltus4M0sw2etnXnXQVsXIJ7PS1lmnvbOxZPvvXKuXxLj8mtvNqnVlNh+dfWg2hRBjyb/Pe5L39l6FfyF/Aw

Environment

Browser: Any
CesiumJS Version: 1.126
Operating System: Any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions