Cesium: Removal of CzmlDataSource from Viewer breaks the Viewer

Created on 12 Mar 2019  路  12Comments  路  Source: CesiumGS/cesium

I am using Cesium to display a subset of the Iridium Next constellation, and I am loading sats via the following:

// satData is the valid CZML sent from the backend over the socket
viewer.dataSources.add(Cesium.CzmlDataSource.load(satData)).then(function (datasource) {
                    ds = datasource;
                });

and then I am attempting to remove it when the socket that sent the satData dies as such:

if (viewer.dataSources.contains(ds)) {
            // satData represent whichever data was past to the frontend from the socket that just disconnected
            var removalPromise = viewer.dataSources.remove(ds);
            Cesium.when(removalPromise, function() { console.log('The promise has resolved') });
}

When I get here, ONLY WHEN THERE ARE MULTIPLE SATS IN THE VIEWER (ala satData1, satData2, etc) I get the following error:

DeveloperError: This object was destroyed, i.e., destroy() was called. Error at new DeveloperError  
 (webpack:///./node_modules/cesium/Source/Core/DeveloperError.js?:43:19) at  
 PolylineCollection.throwOnDestroyed (webpack:///./node_modules/cesium/Source/Core/destroyObject.js?:45:19) at
 PrimitiveCollection.update 

(webpack:///./node_modules/cesium/Source/Scene/PrimitiveCollection.js?:368:27) at PrimitiveCollection.update  

(webpack:///./node_modules/cesium/Source/Scene/PrimitiveCollection.js?:368:27) at PrimitiveCollection.update 

(webpack:///./node_modules/cesium/Source/Scene/PrimitiveCollection.js?:368:27) at  

updateAndRenderPrimitives (webpack:///./node_modules/cesium/Source/Scene/Scene.js?:2936:27) at  

executeCommandsInViewport (webpack:///./node_modules/cesium/Source/Scene/Scene.js?:2775:13) at  
 updateAndExecuteCommands (webpack:///./node_modules/cesium/Source/Scene/Scene.js?:2583:13) 

at render (webpack:///./node_modules/cesium/Source/Scene/Scene.js?:3223:9) at tryAndCatchError  
 (webpack:///./node_modules/cesium/Source/Scene/Scene.js?:3243:13)

Apologies for the weird line breaks. Thanks for the help!

category - data sources type - bug

Most helpful comment

I have verified I'm calling viewer.dataSources.remove with the correct argument and it's not trying to be removed twice. I'll try to get an example put together at some point.

All 12 comments

Thanks for the bug report @BenjaminWinks! Can you share sample data that reproduces this error? It would be really helpful for us to have that and a short Sandcastle Example to reproduce the crash.

I can't reproduce it in the sandcaste because of the way the data comes in - I can't get websockets working with the sandcastle, so it seems like an exercise in futility at the moment - if I come across more time I will. I just used the satellite czml in the sandcastle as a starting point and renamed them.

Could be a typo, but you should be passing ds to viewer.dataSources.contains() instead of satData. And likewise with the call to viewer.dataSources.remove().

Can you reproduce by just inlining several valid data structures then adding them dynamically with a setTimeout? If adding dynamically via timeout doesn't break things but adding dynamically based on send-via-websocket, that would be pretty weird, right?

Since we weren't able to reproduce this, I'm going to close this issue. If you're still having trouble feel free to re-open it. Thanks!

I'm running into this exact same problem as well. Trying to remove multiple dataSources causes Cesium to crash. It works fine for just one, but not when I attempt to remove the second element.

I would suggest to both the original author and Isaac that you make sure you're logging every call to viewer.dataSources.remove with the argument, to be absolutely sure that you're not trying to remove anything twice. If you can guarantee that remove is never being called with the same argument twice, reproducing this behavior in Sandcastle would be extremely valuable toward getting it fixed.

I have verified I'm calling viewer.dataSources.remove with the correct argument and it's not trying to be removed twice. I'll try to get an example put together at some point.

Any update on this issue? I've updated to Cesium 1.74 and still experiencing this issue. As previously stated, I'm unable to provide the CZML files.

Please look at this example error. It is loading 2 different czmls. A setTimeout is set and will run removeAll() and error. If only one czml is added (the other is commented out) removeAll works fine, as does the individual remove(). I've been trying to fix/circumvent this for hours since I'm handcuffed by it. For my application, I'm trying to load and at times remove multiple, much larger czmls and it is necessary I free up memory instead of just hiding them. I believe it has something to do with the time ranges/clock. Because, when I add another czml without time ranges/clock, removeAll() works with that and just one of these timed czmls. I've tried removing various parts of the 2nd czml to pursue that theory and still can't get it to work.

Sandcastle Example

@hpinkos can you reopen this ticket since @Trylor has provided an example via Sandcastle of the issue at hand. Thanks.

@Trylor check out #9154 where I created another ticket related to this issue that has some test cases I listed out. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thw0rted picture thw0rted  路  4Comments

JacksonBates picture JacksonBates  路  3Comments

nikakhov picture nikakhov  路  4Comments

worlddai picture worlddai  路  3Comments

GatorScott picture GatorScott  路  3Comments