cesium
cesium copied to clipboard
Crash when removing multiple CustomDataSources with CallbackProperties
Clicking "remove" will throw the following error (I'm showing the unminified error):
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new DeveloperError (http://localhost:8080/Source/Core/DeveloperError.js:43:19)
at PolylineCollection.throwOnDestroyed (http://localhost:8080/Source/Core/destroyObject.js:45:19)
at PrimitiveCollection.update (http://localhost:8080/Source/Scene/PrimitiveCollection.js:369:27)
at PrimitiveCollection.update (http://localhost:8080/Source/Scene/PrimitiveCollection.js:369:27)
at PrimitiveCollection.update (http://localhost:8080/Source/Scene/PrimitiveCollection.js:369:27)
at updateAndRenderPrimitives (http://localhost:8080/Source/Scene/Scene.js:2937:27)
at executeCommandsInViewport (http://localhost:8080/Source/Scene/Scene.js:2776:13)
at updateAndExecuteCommands (http://localhost:8080/Source/Scene/Scene.js:2584:13)
at render (http://localhost:8080/Source/Scene/Scene.js:3224:9)
at tryAndCatchError (http://localhost:8080/Source/Scene/Scene.js:3244:13)
This only happens under very specific conditions. It will NOT happen if:
- You comment out one of the datasources.add lines like
viewer.dataSources.add(dataSource2);
- If only one of the entities has a callback property (try uncommenting the positions line
positions : Cesium.Cartesian3.fromDegreesArray(poss1)
)
It also works fine if you remove the entities directly from each dataSource, as opposed to removing the dataSource itself.
There aren't any Sandcastle examples using CustomDataSource to group entities this way, so I'm not sure if this is expected. My workaround is to just store the entities yourself in an array and handle iterating through and removing when you need to remove a group.
At first glance, this looks like a clear cut bug on our end. Should be easy to figure out with the reduced test case. Thanks!
hello, team. I'm having this same issue and wanted to check on the status of the bug fix. Are there any other identified workarounds at this time?
I'm using Resium in a React project, and whenever I have more than one CustomDataSource that includes a PolylineGraphics Entity that is using a CallbackProperty I will receive this same error when navigating to another page within the application. Removing the CallbackProperty, the PolylineGraphics Entity, or the additional CustomDataSources resolves the issue.
Any update on this? I've reported the issue before that datasources can not be consecutively removed without an error being trigged.
Having the same problem working with resium. when i move out of the component i get this error that crashes my whole app. i try to destroy the modelRef in the useEffect but that doesnt happen. Any updates on this bug?
Any news on this?
I was really happy to use the CallbackProperty api since it improves my app's performance significantly.
But unfortunately since I have several data sources my app crashes a lot
Up vote this, since there doesn't appear to be any news.
I'm using cesium/resium in react with multiple CzmlDataSource, and it crashes when I go to another page of my app, the app crashes.
Same here. Using resium, drawing Polyline with CallbackProperty as the positions argument of the Polyline. The app crashes when calling viewer.datasources.remove(data_source) when data_source contains the Polyline with the CallbackProperty. Using Polyline without CallbackProperty resolve the issue, but we need the CallbackProperty since we update the position of the Polyline multiple times/sec.
Edit: added sandcastle example https://sandcastle.cesium.com/#c=tVRdb9owFP0rV+wFJOrYTpzYQNEkJu1l0qox7WXZg5u4xWo+UOzQsan/fTekFGhZ1T3sAck3+Byfc318gwA+aK+XddtkBhpT1hsDWaPdCsxPXa4LM4GV92s3CYJb61ftNcnqMlgYZ9vy4zLIdovAOtcaFySJkGmVVlldOQ8ba+5NA5dQmXvoEeTb7tswHfTARV15bSvTpIPRtEMGASwaoz2KaJ2vS8hRHbidPLcnzp8Us1P2xQ5zMITnlNtDyfpTnpPwfyLhPUlvjhxYHNF5PjyS9qZd/Mn20teNgXVdbAtsCC6c9RaVjqF1BqyHArvSgK1goYviWmd3V029No3f7h3tsVd7aNed72kFJ+5043Glq3DIYsmZIrHgkvGEyWgMF5GKaBwzwjmVkoZCjSGiLI4jSVQSJkwwSqPR+O+kF0hFGdImXAmFNFQibcgxGmFMGI24EImMwjGIEAsVEywYS6RUo7T6MT3E54Ud/rqdC8lpSCVJGJUMBUuGBwsec8UlCbmSVAiGfsJIxbFSRFCG2wWVr9uJVRJTRhRH/wpb1dmJGMNGMSI4l6HkIhTYJtGdRQmLhYgiGfMnO4dMm8qjFYN3iikAXx+nO62OskP2O3dx+d3p27djArsSDgmZnGo/DcdwOILL+ZlsjOFGF8705gHube5XE+Bd9ZBWD30uj4L6/yXxN0nCbn7px9RR8+AdA33TvQ8BzmB+chwWzvivtjR16x9P3Kk88yT7sff87T5gRCmlo+lgPEgH0w67/wHMnN8WZt4XAO9tua4bD21TDAkJvMHJiRfugus2uzOeZM6Npo/I4Bg6y+0GbH55ZiBCVmjn8J+btiiW9pdJB/NZgPtfQIta57a6/bwxTaG33bYVm3/qPxJCZgGW55G+rvFqmmfMfwA
@mramato I know your comment was from 4+ years ago but I've spent some time digging deeper into this issue and hope we can find a solution together. We recently upgraded to version 1.108 and this bug is now causing frequent crashes for us. I've spent some time looking into it and I have some findings to share.
Our system creates and renders two Polylines when an object is selected and those Polylines are removed when the object is deselected. While the Polylines are related to the selected object, they are not related to eachother so they are created and managed via distinct CustomDataSource objects. This bug crashes our system every time an object is deselected because of the subsequent removal of the two Polylines. We use Callback properties for the positions of the Polylines because this is the only way to render them without a flicker.
For the sake of clarity, I'll refer to Polylines that use Callback properties for the positions as "Callback Polylines" and Polylines that use Constant properties for the positions as "Constant Polylines".
As far as I can tell, the following is true:
- The crash only occurs when 2 or more Callback Polylines are removed from separate DataSources.
- The crash does not occur if there is still a Callback Polyline in the system.
- The crash will occur even if there is still a Constant Polyline in the system.
- The amount of time between the removal of the subsequent Callback Polylines does not matter. The crash happens even when the removals occur many seconds apart.
Consider cases where you have 2 Callback Polylines and 1 Constant Polyline that are all removed in various orders:
Case 1. Remove the Constant Polyline first: Crashes when the 3rd polyline is removed Case 2. Remove the Constant Polyline second: Crashes when the 3rd polyline is removed Case 3. Remove the Constant Polyline third: Crashes when the 2nd polyline is removed
The system still crashes even when there is still a Constant Polyline in the collection. However, it will not crash if there's still a Callback Polyline in the system.
Consider the same cases shown above except this time with a 4th Polyline: a Callback Polyline that never gets removed. None of these cases cause a crash because the PolylineCollection is presumably never destroyed.
Case 1. Remove the Constant Polyline first: No crash Case 2. Remove the Constant Polyline second: No crash Case 3. Remove the Constant Polyline third: No crash
Everything seems to indicate the PolylineCollection is being destroyed when the final Callback Polyline is removed from the system. I suspect the crash occurs when that destroyed PolylineCollection is accessed when it should not be. I've tried to identify the problematic code but I'm not very familiar with the internal Cesium code so my efforts have been unsuccessful.
Questions:
- Does the PolylineCollection need to be destroyed when the final Polyline is removed? Is there much of a penalty to retain an empty collection?
- Do you have any idea where the destroyed PolylineCollection is being accessed incorrectly? Perhaps some code needs to be updated to include guard checks to see if has been destroyed?
- Do you believe line 877 of PolylineGeometryUpdater.js could be the culprit?
Please let me know if there's anything else I can do to help find a solution to this bug.
@mangodudemartin
hello, team. I'm having this same issue and wanted to check on the status of the bug fix. Are there any other identified workarounds at this time?
I'm using Resium in a React project, and whenever I have more than one CustomDataSource that includes a PolylineGraphics Entity that is using a CallbackProperty I will receive this same error when navigating to another page within the application. Removing the CallbackProperty, the PolylineGraphics Entity, or the additional CustomDataSources resolves the issue.
Unfortunately the only workaround I have found is to force the system to never destroy the PolylineCollection by never allowing it to become empty. This is obviously not desirable but it can help stabilize your app if it is plagued by crashes.
const viewer = new Cesium.Viewer("cesiumContainer");
// Add this empty Polyline and never remove it. No more crashes.
viewer.entities.add({
id: "do-not-remove",
polyline: {
positions: new Cesium.CallbackProperty( () => [], false),
}
});
I believe this issue and #9154 - Cesium crashes when removing multiple dataSources are caused by the same underlying bug. Upon reading that issue, it sounds like the polylines are the culprit.
Any updates on this issue?
Resolved in https://github.com/CesiumGS/cesium/pull/11640