I'm running a custom build of Godot 4.6.2-stable on Mac OS Tahoe with .NET 8.
Running 2dog tests via dotnet test and Rider crash on Godot engine start.
I have analyzed and "fixed" this locally with AI, but I wanted to report the details to validate if these are actually the issues they appears to be (and if so, if I should create a corresponding issue(s) in the Godot repo) or if I'm just doing something dumb.
Issue 1: NSInternalInconsistencyException
On launch, Godot crashes with:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'API misuse: setting the main menu on a non-main thread. Main menu contents should only be modified from the main thread.'
This appears to be a MacOS AppKit error due to the xUnit process owning the main thread, a child thread that owns the Godot engine trying to do UI updates, and AppKit crashing on that violation.
The fix here was too move the --headless check earlier in the macos setup process so OS_MacOS_Headless could be created if --headless was passed in.
Issue 2: OS.has_feature("dotnet")
Godot only initializes .NET in non-tools builds when OS.has_feature("dotnet") is true at gd_mono.cpp (line 610). Normal C# export gets that from GodotTools _GetExportFeatures() at ExportPlugin.cs (line 30). The libgodot/xUnit path is not an export, so the feature is absent. This was the fix I used. This seems like there should probably be a simpler way.
Issue 3: hostfxr initialize
gd_mono.cpp (line 402) calls hostfxr_initialize_for_dotnet_command_line, which is for starting a new process rather than loading a .net component into an existing process.
I got around this by having 2dog pass an init function pointer and having godot accept it, which seems to fix the issue.
Conclusion
I'm not at all an SME in this stuff, so these fixes are almost entirely AI slop. Let me know what your thoughts are on next steps.
I'm running a custom build of Godot
4.6.2-stableon Mac OS Tahoe with .NET 8.Running 2dog tests via
dotnet testand Rider crash on Godot engine start.I have analyzed and "fixed" this locally with AI, but I wanted to report the details to validate if these are actually the issues they appears to be (and if so, if I should create a corresponding issue(s) in the Godot repo) or if I'm just doing something dumb.
Issue 1: NSInternalInconsistencyException
On launch, Godot crashes with:
This appears to be a MacOS AppKit error due to the xUnit process owning the main thread, a child thread that owns the Godot engine trying to do UI updates, and AppKit crashing on that violation.
The fix here was too move the
--headlesscheck earlier in the macos setup process soOS_MacOS_Headlesscould be created if--headlesswas passed in.Issue 2: OS.has_feature("dotnet")
Godot only initializes .NET in non-tools builds when OS.has_feature("dotnet") is true at gd_mono.cpp (line 610). Normal C# export gets that from GodotTools _GetExportFeatures() at ExportPlugin.cs (line 30). The libgodot/xUnit path is not an export, so the feature is absent. This was the fix I used. This seems like there should probably be a simpler way.
Issue 3: hostfxr initialize
gd_mono.cpp (line 402) calls
hostfxr_initialize_for_dotnet_command_line, which is for starting a new process rather than loading a .net component into an existing process.I got around this by having 2dog pass an init function pointer and having godot accept it, which seems to fix the issue.
Conclusion
I'm not at all an SME in this stuff, so these fixes are almost entirely AI slop. Let me know what your thoughts are on next steps.