Performance issue with Label (num characters) and CLAMP_TO_GROUND

Adding entities in Cesium.js using HeightReference = CLAMP_TO_GROUND is generally very costly for performance. The problem seems worse with Labels than Billboards, and strangely enough the performance decreases with not only the number of entities but primarily the length of the text labels (number of characters).

Rendering 1000 labels with 5 characters works quite well. But if I increase the number of characters to 20 or 100 the application becomes unusable. This only an issue when HeightReference is used to clamp the entities to underlying terrain.

As the letters are not individually placed relative to ground I see no reason why the number of characters should effect performance here.

Is there some configuration I’m missing or is there a bug here somewhere?

Sandcastle demo

Tested Version: Cesium.js 1.131

To Reproduce:

  1. Make sure “Clamp to Ground” is active
  2. Enable “1000 Entities” (should work fine, 60fps)
  3. Enable “100 Characters” (unusable, browser hangs)

I think that the performance issue here might not directly (or not only) be related to clamping: Displaying 1000 labels with 100 characters each just is a lot of rendering to do. Specifically, when following the steps that you described, then switching to “100 Characters” does make the browser hang for quite a while (and I assume that this is the whole initalization of the labels and the generation of the texture atlas). But afterwards, the FPS seem to be “reasonable”.

It still looks like the performance drops when navigating - i.e. when moving the camera - and I cannot explain this, so there’s certainly something to have a closer look at.

(Cross-link to Performance issue with Label (num characters) and CLAMP_TO_GROUND · Issue #12719 · CesiumGS/cesium · GitHub )

Try the same reproduction steps in the sandcastle but with first selecting “None” instead of “Clamp to Ground” in the first dropdown.

Switching to 100 characters in this case is instant. This is why I suspect this issue is related to clamping.