Performance tanks in 2D view but is fine in 3D

I’m currently using CesiumJS to plot 10k - 100k polylines. This runs fine in the 3D globe view, however performance drops heavily in the 2D view. Any advice on how to improve performance would be greatly appreciated!

Benchmarks:

15k polylines: 100 fps in 3D view, 40 fps in 2D view.
50k polylines: 70 fps in 3D view, 20 fps in 2D view.
107k polylines: 60 fps in 3D view, 10 fps in 2D view.

Notes:

  • All measurements were done from a static view, without any user input.
  • Performance does not vary much depending on whether or not I am zoomed in or not, so it doesn’t seem to be related to how many entities are on screen?
  • According to the profiler the ._setUniforms function is response for the majority of the performance cost in 2D, taking up ~42% of rendering time.
  • Tested in Firefox.

Structure:

  • The polylines are created using the entity API, as the user needs to be able to individually select them and view related information.
  • Polylines are grouped together into CustomDataSources, with each one consisting of between 100-1000 polylines each.
  • Polylines do not move and will only occasionally change color/visibility (all at once) based on user input.
  • Each line is defined by 3 points and uses the geodesic arctype.
  • The polyline materials only use the Cesium.Color class.
  • Our code does not differentiate between 2D or 3D view.

Thanks!

2 Likes

Interestingly, this issue does not impact Columbus view, even though visually Columbus view and 2D are the same.

I’ve created a basic Sandcastle example here.

As such, a basic workaround is to replace 2D view with Columbus view and then snap the camera’s y direction to 0 to simulate 2D view:

viewer.scene.morphComplete.addEventListener(() => {
    if (viewer.scene.mode == Cesium.SceneMode.COLUMBUS_VIEW) {
        viewer.camera.flyTo({
            destination: new Cesium.Rectangle(-Math.PI, -Math.PI / 2, Math.PI, Math.PI / 2),
            duration: 0,
        });
    }
});
1 Like

Hi,

I’m facing the same issue even with only markers and clusters (>3K).
That and also a misplacement of the markers and clusters in 2D but not in Columbus as well (especially on the top of the map).

Did you find out why and/or a fix for it?

Thank you.

Hi @Anoerak ,

Thanks for your post and for being part of the Cesium community.

We have an open issue here for a fix to this issue Infinite scroll 2D is really slow with polygons · Issue #5026 · CesiumGS/cesium · GitHub. Please feel free to add any additional information to the issue.

Also, it would be helpful if you could create and share a sandcastle example of what you are seeing, similar the useful sandcastle example the original poster shared? This will help in diagnosing the issue and testing potential fixes.

Thanks,

Luke

Hi @Luke_McKinstry

Here is an example of the issue I’m facing:
Cesium sandcastle - 2D issue with performance, markers and clusters

I added an FPS meter to monitor performance and a button to toggle clustering on/off. Here’s what I’ve observed:

  • Performance drops in 2D, but not in 3D or Columbus View.

  • Cluster behavior differs between modes: for example, Scandinavia doesn’t seem to generate any clusters in 2D, whereas it works as expected in 3D/Columbus.

  • Zooming over Norway in 2D, markers sometimes don’t appear, while they render correctly in Columbus View.

  • Replacing points with billboards worsens the issue in 2D, sometimes placing billboards outside the visible map.

Hopefully you can replicate and perhaps let me know if I am doing something wrong or perhaps it will help pinpoint the issue.

Thanks!

Sebastien

Hi again,

After experimenting with Sandcastle, I noticed that the misplacement and disappearance of markers in 2D doesn’t occur when using billboard entities instead of point.

Here’s a second Sandcastle example where the points have been replaced with billboards, and both clusters and individual markers are correctly rendered.

Cesium sandcastle - 2D issue with performance, markers and clusters (using billboards instead of points)