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 another crash caused by destroying CesiumIonSession while it is doing network requests #499

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

kring
Copy link
Member

@kring kring commented Sep 2, 2024

In #479, I made some improvements to CesiumIonSession to a) keep the managed object alive while requests are in progress, and b) check that they haven't been destroyed (such as by an AppDomain unload) when the request completes. This significantly improved the stability of the tests, but I was still seeing an occasional access violation when running tests. For example, here:
https://github.com/CesiumGS/cesium-unity/actions/runs/10658298813/job/29539138580

I was able to reproduce this on my machine by running the tests repeatedly, and the cause was that the CesiumIonSession was being destroyed while one of the refresh methods was running. Looks like I missed those when making the previous changes.

This fix is an improvement, but still isn't perfect. During AppDomain unload, it's possible for the finalizer to run in another thread in between when the validaty of the session is checked and when we use the corresponding native object, which will still result in a crash. This PR narrows the window. The only complete solution, as far as I can see, will be allowing the native world to share ownership of the Impl objects with the managed world, via reference counting.

@kring kring added this to the September 2024 Release milestone Sep 2, 2024
@kring
Copy link
Member Author

kring commented Sep 2, 2024

Merging this for tomorrow's release (it's very low risk).

@kring kring merged commit c48ce92 into main Sep 2, 2024
7 checks passed
@kring kring deleted the more-ion-client-safety branch September 2, 2024 07:05
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.

1 participant