.NET 9 Mono #811
Labels
Improvement
New feature or request
.NET
Pull requests that update .net code
Planned
This issue is planned to be worked on
Context
We discussed this in Discord, and there are a few main problems to using .NET 9 with Unity.
Reference: https://unity.com/blog/engine-platform/porting-unity-to-coreclr
Ensure objects don't move.
Unity stores
MonoObject*
pointers to access managed objects. This can be to invoke methods on them (such asAwake
), deserialize fields, or anything else that the Mono API allows.Compacting can be disabled with native patching or a custom build.
https://github.com/dotnet/runtime/blob/0cba4a126edefdc0584e21fb7e180e44aa2e7b88/src/coreclr/gc/gc.cpp#L45144
Ensure objects aren't collected unless there are no references in native code.
Unity uses Boehm to search the entire stack. We'll probably have to do the same. Keeping objects alive forever is likely not an option.
Handle any AppDomain issues.
This might not be a runtime issue. The primary problem with app domains was Unity using them to reload assemblies in the editor.
Mono C APIs
This was briefly mentioned above, but Mono exposes a bunch of C APIs that Unity uses. CoreCLR does not expose these APIs. We either have to recreate them or use the .NET 9 Mono code, which is slower, but should work out of the box. .NET 9 Mono is used for Android and WASM.
https://github.com/dotnet/runtime/tree/main/src/mono
The text was updated successfully, but these errors were encountered: