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

Improve stability on AppDomain reloads. #536

Merged
merged 3 commits into from
Jan 1, 2025
Merged

Conversation

kring
Copy link
Member

@kring kring commented Dec 13, 2024

Fixes #525
(at least, it should be much better!)

This PR makes two changes that should significantly decrease the chances of a crash when Unity reloads AppDomains:

Unity reloads AppDomains a lot, so anything we can do to more it work more reliably is likely to be a big win for users. Unfortunately, this probably isn't a 100% solution. We really need #18, for one thing. For another, it's not clear to me (even after looking at the Mono source code) whether the "object is from a previous AppDomain" detection is 100% reliable. It might be best effort, and sometimes just give you the "wrong" object instead of throwing an exception.

If that's the case, we might ultimately need to either: 1) implement a way to reliably stop and unload all of the Native world when the AppDomain unloads, or 2) extend our native ObjectHandle to record the AppDomain.Id and verify it's still correct before dereferencing. Option (2) is probably more realistic.

This PR also updates cesium-native to the current head of main.

@j9liu j9liu self-requested a review December 16, 2024 21:24
@kring
Copy link
Member Author

kring commented Jan 1, 2025

I'm merging this for tomorrow's release.

@kring kring merged commit 0d8f0e0 into main Jan 1, 2025
7 checks passed
@kring kring deleted the domain-reload-stability branch January 1, 2025 12:13
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.

Unity crashes when reloading domains
1 participant