Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when removing multiple CustomDataSources with CallbackProperties #7758

Closed
OmarShehata opened this issue Apr 18, 2019 · 12 comments
Closed

Comments

@OmarShehata
Copy link
Contributor

Forum link

Sandcastle

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.

@mramato
Copy link
Member

mramato commented Apr 18, 2019

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!

@mangodudemartin
Copy link

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.

@icarter09
Copy link

icarter09 commented Nov 6, 2020

Any update on this? I've reported the issue before that datasources can not be consecutively removed without an error being trigged.

@nadavtal
Copy link

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?

@yonzmeer
Copy link
Contributor

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

@adamdva
Copy link

adamdva commented Jul 18, 2022

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.

@yfrans
Copy link

yfrans commented Sep 11, 2022

@rropp5
Copy link
Contributor

rropp5 commented Aug 31, 2023

@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:

  1. Does the PolylineCollection need to be destroyed when the final Polyline is removed? Is there much of a penalty to retain an empty collection?
  2. 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?
  3. 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.

@rropp5
Copy link
Contributor

rropp5 commented Aug 31, 2023

@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),
  }
});

@rropp5
Copy link
Contributor

rropp5 commented Sep 5, 2023

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.

@rropp5
Copy link
Contributor

rropp5 commented Sep 20, 2023

Any updates on this issue?

ggetz added a commit that referenced this issue Jan 16, 2024
Fix crashes due to shared PolylineCollection among all CustomDataSources #7758 #9154
@jjhembd
Copy link
Contributor

jjhembd commented Feb 1, 2024

Resolved in #11640

@jjhembd jjhembd closed this as completed Feb 1, 2024
pupitetris pushed a commit to pupitetris/cesium-webxr that referenced this issue Mar 4, 2024
Remove PolylineCollections from the Scene before they are destroyed. This causes CesiumGS#7758 and CesiumGS#9154.
pupitetris pushed a commit to pupitetris/cesium-webxr that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Notable backlog items
Development

No branches or pull requests