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

Fix crashes due to shared PolylineCollection among all CustomDataSources #7758 #9154 #11640

Merged
merged 12 commits into from
Jan 16, 2024

Conversation

rropp5
Copy link
Contributor

@rropp5 rropp5 commented Nov 21, 2023

PolylineCollections are destroyed by the PolylineGeometryUpdater but are still available on the Scene and cause Cesium to stop rendering when they are accessed.

This commit ensures the destroyed PolylineCollections are removed from the Scene in the destroy function of PolylineGeometryUpdater so they are not evaluated in the next render cycle of the Scene.

This resolves the crashes reported under #7758 and #9154.

@cesium-concierge
Copy link

Thank you so much for the pull request @rropp5! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

  • ❌ Missing CONTRIBUTORS.md entry.
  • ❌ Missing CLA.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.

@ggetz
Copy link
Contributor

ggetz commented Nov 21, 2023

Hi @rropp5. We'll need a signed Contributor License Agreement (CLA) to review this PR. Please send in a Contributor License Agreement and comment back here to let us know to check this!

@rropp5
Copy link
Contributor Author

rropp5 commented Nov 21, 2023

@ggetz I just submitted. Thanks!

@rropp5
Copy link
Contributor Author

rropp5 commented Nov 21, 2023

My second commit addresses a case that I had fixed locally and neglected to push in the original commit.

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 1, 2023

@ggetz Is there anything else I should do to make this PR as smooth as possible? Thanks!

@ggetz
Copy link
Contributor

ggetz commented Dec 4, 2023

Apologies for the delay @rropp5!

Please sync the latest upstream code and update CHANGES.md with a summary of your fix.

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 14, 2023

@ggetz Apologies for the delay but I just updated the CHANGES.md. Thanks!

@ggetz
Copy link
Contributor

ggetz commented Dec 15, 2023

Thank @rropp5! While I think this is a good change, I'm not sure it fixes #7758 and #9154. I'm able to reproduce errors in the Sandcastle examples in both of those issues.

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 15, 2023

@ggetz Oh bummer, this was causing a crash in my system that looked a lot like the problems in those issues.

It resolved the crashes I was personally experiencing so I thought it covered those sandcastles as well. I don't have the best environment setup to test sandcastles but I'll have to figure that out moving forward.

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 15, 2023

@ggetz I figured out how to get the Sandcastle setup locally and did some digging into #7758. I was able to fix that crash by adding a similar fix to the DataSourceDisplay (remove primitives from the scene when they are destroyed).

I will try to find some time to test #9154 this weekend and see if I can knock out both issues at once. I'll keep you posted. Thanks!

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 16, 2023

@ggetz I was able to find the crux of the issue this evening: all CustomDataSources were sharing a single PolylineCollection instance. This created a lot of different cases that would cause the crashes reported under #7758 and #9154.

I've updated the PolylineGeometryUpdater to uniquely identify each PolylineCollection for each CustomDataSource and this does fix #7758 and #9154 for me locally.

Additionally, after thinking about it, I decided to revert my earlier changes locally to see if they were still necessary and it turns out they aren't. In my opinion, my most recent commit (b7928c9) is the most correct solution so I'm going to revert the earlier commits. Please take a look and let me know if you agree!

If you think there's a good reason to keep some of those changes, I'm happy to discuss. Thanks for the help.

@rropp5 rropp5 changed the title Remove destroyed PolylineCollection from Scene #7758 Fix crashes due to shared PolylineCollection among all CustomDataSources #7758 #9154 Dec 16, 2023
rropp5 and others added 10 commits December 18, 2023 21:16
Remove PolylineCollections from the Scene before they are destroyed. This causes #7758 and #9154.
CustomDataSources were using the same PolylineCollection to store their Polyline primitives. When a CustomDataSource was destroyed, it was also destroying the PolylineCollection. Since that object was shared and other CustomDataSources remained in the system, this would cause Cesium to stop rendering when the destroyed PolylineCollection was accessed.

Solution: use distinct PolylineCollections per CustomDataSource by keying PolylineCollections with the PrimitiveCollection's guid in addition to the Scene id.
@romejoe
Copy link
Contributor

romejoe commented Dec 21, 2023

I'm not totally sure, but I think I ran into this problem last night as well, but using CZMLDataSources

@rropp5
Copy link
Contributor Author

rropp5 commented Dec 21, 2023

I'm not totally sure, but I think I ran into this problem last night as well, but using CZMLDataSources

Given the nature of the fix, I think the problem is more specific to the PolylineGeometryUpdater and not so much the CustomDataSource. It just happens that most of the reported issues I found were linked to creating Polylines via the CustomDataSources.

@ggetz
Copy link
Contributor

ggetz commented Jan 12, 2024

Thanks @rropp5! Sorry for the delay in review here. Happy to see you've identified a fix.

Would you mind updating your branch, and moving you entry in CHANGES.md to the February release?

@rropp5
Copy link
Contributor Author

rropp5 commented Jan 13, 2024

@ggetz done!

@ggetz
Copy link
Contributor

ggetz commented Jan 16, 2024

Fantastic! Thanks for the fix @rropp5!

@ggetz ggetz merged commit 59244ce into CesiumGS:main Jan 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants