Hey Community,
I have encountered quite a problem. When zooming around and showing labels depending how zoomed in I am for clustering, whenever the label is added that is different will cause the whole screen to go black. I first thought it was because I was doing something silly however, I have a sandcastle link to reproduce.
To reproduce
Step 1: Run the code
Step 2: zoom into the label with text 1
Step 3: when zooming in you will see a flash
Link to reproduced code
I screen recorded to slow it down and see what it looks like and its black
Hopefully someone can tell me what I am doing wrong ![:pleading_face: :pleading_face:](https://emoji.discourse-cdn.com/twitter/pleading_face.png?v=12)
Kind regards
Riley
Hi Riley,
Thanks for your post.
I see you are using a PointPrimitiveCollection
for your point locations. The clustering logic in Cesium is connected to the DataSource
class*. The general flow is that you load the data into a DataSource
, enable clustering on that DataSource by setting DataSource.clustering.enabled
to true, and then set the ...clustering.pixelRange
and ...clustering.minimumPixelSize
properties to control the clustering behavior.
We have a sandcastle example here which shows this basic setup. Cesium Sandcastle
*Note: There are actually a bunch of DataSource classes to choose from CustomDataSource
Do you think this will fit your use case? If not or if you have questions please let us know and we would be happy to try to help more.
Thanks,
Luke
My understanding (that might very well be wrong) was that this refers to the flickering itself, and not to the clustering functionality.
Specifically: Adding a new label causes a short flicker. (I tried to record it, but … it’s only one frame, apparently, and even with 60fps, I couldn’t capture it). For me, it happens in this example, when the third label is added by clicking ‘And another one’:
2 Likes
If ^ this was right: There might be some shaky promise handling around cesium/packages/engine/Source/Scene/Billboard.js at dc667cd6decdaf14079038bc32773f421e585724 · CesiumGS/cesium · GitHub , and the flickering seems to be related to TextureAtlas.resizeAtlas
being called. Maybe that helps as a pointer.
1 Like
Hi there,
There is issues with our clustering as removing this from the app and keeping the labels they still cause the screen to flash
Cheers
Riley
Hi there,
Yes you are correct the flickering is the issue. In the example I can make it happen once but when you have changing labels depending on user interaction this can be a lot more frequent.
For example, panning around the map would make it flash as other labels will be loaded in.
Any advice on if there is a way to stop this would be excellent
Cheers
Riley
@Luke_McKinstry I zoomed into that and tried some workarounds, like not using LabelCollection
and adding the labels to an EntityCollection
instead. But it seems to still use the TextureAtlas
under the hood, which I currently suspect to be the culprit here. This can to some extent be confirmed by setting the defaultInitialSize
to something like (2048, 2048), which causes it to no longer be resized, and to no longer flicker. This may be connected to some open questions about possible ‘floating promises’ - roughly: It might be that it is calling resizeAtlas
in some pending promise, at a point where its framebuffer handling interferes with the normal rendering.
Looks like we have an issue open for this Cesium Map flickers when TextureAtlas resizes (like when adding labels) · Issue #12231 · CesiumGS/cesium · GitHub and are actively working on it.
Thanks @Marco13 for the extra context and debugging insights.
@rileyhowley note that you encountered this problem as well to help prioritize and link this thread for the debugging insights.
1 Like