cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Infinite scroll 2D is really slow with polygons

Open hpinkos opened this issue 9 years ago • 7 comments

  • Open the viewer
  • Drag drop the attached GeoJSON file
  • Switch to 2D mode

The map is lags pretty badly in 2D infinite scroll mode. The performance is fine in 3D and is much better if you use the rotatable 2D map instead

vienna.geojson.txt

hpinkos avatar Feb 22 '17 19:02 hpinkos

@bagnell a number of users on the forum have been complaining about slow polygons when upgrading from 1.2x to 1.30+. Do you know of anything that changed that might have caused that?

hpinkos avatar Mar 02 '17 17:03 hpinkos

@hpinkos do you have links to the forum issues?

@bagnell sounds like something is being computed per-vertex/triangle per-frame. Perhaps it is missing a coarse-grained check?

pjcozzi avatar Mar 06 '17 16:03 pjcozzi

Forum posts:

https://groups.google.com/d/msg/cesium-dev/hXC8gxdi3uE/ZBWHUL6jAgAJ https://groups.google.com/d/msg/cesium-dev/wT2jkCrvvGQ/WdrP3QgmAwAJ

hpinkos avatar Mar 06 '17 16:03 hpinkos

Also reported by @forest21000 in #7694

hpinkos avatar Apr 01 '19 15:04 hpinkos

Reported again by @zhangchn in https://github.com/CesiumGS/cesium/issues/10304.

ggetz avatar Apr 19 '22 14:04 ggetz

Reported again by @zhangchn in #10304.

The performance issue in SCENE2D could NOT be alleviated by using MapMode2D.ROTATE.

zhangchn avatar Apr 20 '22 05:04 zhangchn

I am also seeing this same issue, even with MapMode2D.ROTATE enabled. Lower frame rate and higher CPU usage when 2D is compared to 3D.

0dividedby0-b avatar Sep 12 '24 18:09 0dividedby0-b

Hey folks. Running into a similar issue here. I'll preface this by saying I believe this only affects issues with MapMode2D.INFINITE_SCROLL -- issues that affect both INFINITE_SCROLL and ROTATE might be a separate, unrelated issue.

I did a little debugging, and the following diff to execute2DViewportCommands seems to fix it my performance issues...

diff --git a/packages/engine/Source/Scene/Scene.js b/packages/engine/Source/Scene/Scene.js
index e438fdf87e..e52b0d2723 100644
--- a/packages/engine/Source/Scene/Scene.js
+++ b/packages/engine/Source/Scene/Scene.js
@@ -3310,8 +3310,10 @@ function execute2DViewportCommands(scene, passState) {
   }
 
   camera._setTransform(transform);
-  Cartesian3.clone(position, camera.position);
+  camera.position.x = position.x;
+  camera.position.y = position.y;
+  // camera.position.z = position.z;
   camera.frustum = frustum.clone();
   passState.viewport = originalViewport;
 }

Setting camera.position.z seems to make the issue come back. Digging a little deeper, it looks like the camera's z is getting set in executeCommands to avoid z-fighting.

https://github.com/CesiumGS/cesium/blob/47b5d295facaca795381bf607b78cc60c643fd85/packages/engine/Source/Scene/Scene.js#L2614-L2617

So this change performed in executeCommands was getting reverted when resetting the camera's position in execute2DViewportCommands. If this seems like a reasonable change, I'm happy to open a PR 😄

cc @ggetz

andrewda avatar Dec 20 '24 22:12 andrewda

This change also appears to fix https://github.com/CesiumGS/cesium/issues/8302 (polyline zIndex issues in INFINITE_SCROLL mode)!

andrewda avatar Dec 21 '24 16:12 andrewda

2 more examples of slow 2D performance for polylines and markers/cluster shared in this forums thread https://community.cesium.com/t/performance-tanks-in-2d-view-but-is-fine-in-3d/42439/3

lukemckinstry avatar Aug 26 '25 17:08 lukemckinstry