-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
C#: Fix editor crashing without a message when .NET is not installed #73815
C#: Fix editor crashing without a message when .NET is not installed #73815
Conversation
It would be great if we could exit gracefully instead of crashing, but I agree that as a short term improvement this is better than nothing (and exiting gracefully from an arbitrary place in the codebase is not trivial). I can test on Linux in a minute. |
A somewhat graceful exit was the plan when I originally wrote this for #72333, but there is no OS::exit, and in the end it doesn't really make a difference for the user, so I just went for a crash instead. I am currently checking on macOS, but my Ubuntu doesn't feel like starting atm, so you checking that would be great. |
Doesn't seem to work for me on Linux (Mageia 9, KDE Plasma on KWin/X11). The project manager runs fine and the console gets those errors:
Then trying to edit an existing C# project, I get a crash with no OS dialog, and the same errors in the console:
I don't seem to hit the condition you're modifying, it crashes earlier on. It should probably raise an error when Since the project manager seems to be doing those checks too, but without crashing, maybe it could already show an error dialog (from Godot itself, not necessarily But for users editing a project directly without going through the project manager we'd still want to at least show the |
Yeah, no sure how this can work on windows, but on mac that condition can't be hit either, so back to the drawing board. |
This works for me on Linux: diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index e277d887fd..27c21693d5 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -399,6 +399,9 @@ void GDMono::initialize() {
ERR_FAIL_MSG(".NET: Failed to load hostfxr");
}
#else
+
+ // Show a message box to the user to make the problem explicit (and explain a potential crash).
+ OS::get_singleton()->alert(TTR("Unable to load .NET runtime, specifically hostfxr.\nAttempting to create/edit a project will lead to a crash.\n\nPlease install the .NET SDK 6.0 or later from https://dotnet.microsoft.com/en-us/download and restart Godot."), TTR("Failed to load .NET runtime"));
ERR_FAIL_MSG(".NET: Failed to load hostfxr");
#endif
} This gets shown when opening the project manager, so I didn't make it crash, but pointed out in the error that it would if the user attempts to create or edit a project. So they get to close the dialog, and then close the project manager. (don't mind the garbage in the window, the dialog is shown so early that the Project Manager hasn't finished rendering) |
276a86f
to
3b3e3b6
Compare
Found the same point as well, it works on macOS and windows as well. |
WDYT of my improved message? I think it's good to give clear expectations for what might happen once they click "ok" :) |
3b3e3b6
to
30d0f34
Compare
I think it's ready for review now? I'd like to merge it now for 4.0 RC 4 :) |
30d0f34
to
6b050a3
Compare
I added the same message (without the crash_now) to the original location as well. because I wasn't completely confused when I put it there originally. It is necessary there, if some .net is installed but it is too old. |
Also for completeness: On mac and windows the splash screen is rendered correctly before the message box pops up, (which is blocking on both) than when you confirm it, either the project manager comes up normally or the editor crashes when editing a project. |
Thanks! |
This only fixes the without a message part, the editor will still crash.
TODO: Verify that
OS::alert()
is either blocking or the message survives a crash on all supported platforms.Windows
macOS
Linux
Fixes No error message in console if .Net is not installed #69034
Fixes Crash on macOS 13 when opening an existing or new project with .NET 6 #73756 (Which seems to have resolved itself, but was likely originally caused by a missing / broken .NET 6 install)