Crash on DataSource removal


Cesium crashes here

when I remove a dataSource.

length == 4

i == 3

dataSources.length == 3

dataSource == dataSources.get(i) == undefined

So, it looks like it is being processed in a worker in the same time I remove it and this is not handled properly.

I’d say an easy fix would be to cycle through dataSources in the reverse order.

Unfortunately, I can’t provide a simple example reproducing this.

Can you confirm this is a bug?

Can you propose a workaround?

Thank you.

None of the code involves web workers, and I don’t see how there could be a callback style race condition either, unless you were removing a dataSource inside of an event thrown by another data source? Without an example it’s going to be hard to reproduce this (any example I write works as expected). Can you explain in more detail where and when you are removing the dataSource?

You are right, it was done in an event.

I (ab)use the first CallbackProperty’s callback as a “frame-start” event.!topic/cesium-dev/TDFqYafkTV8

That explains what happened.

I use DataSources as “folders” to show/hide/remove multiple entities at once.

Now, I’m to find an alternative implementation of “frame-start” event or “folders”.

Please advise.

Thank you.

Sorry I never replied to that other thread. But your use case reminded me of datasource.update which may provide what you need to do. For each custom data source, the update function will be called (if it exists) allowing the source to reconfigure itself each update. Rather than remove the data source completely, you can remove all of the entities from it (and then add them back later).

That being said, the capability will provide exactly what you need and should be available in 1.8. For example, you could have 4 top-level “folder” entities and then a bunch of child entities each with their parent set to one of the folders. Toggling each folder property would cause all of it’s children to be hidden.

So, I’ll wait for 1.8.


FYI, I just opened pull request #2600 to add support, so this should definitely be in 1.8 barring any surprises. I also added a Sandcastle example for showing/hiding groups of entities.