godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.14k stars 20.21k forks source link

Options for dealing with unhandled C# exceptions present in Godot 3 are missing in Godot 4 #73515

Open Zorochase opened 1 year ago

Zorochase commented 1 year ago

Godot version

4.0.dev

System information

N/A

Issue description

In Godot 3, users could subscribe a method to either GD.UnhandledException or AppDomain.CurrentDomain.UnhandledException to, for example, log unhandled exceptions to the Output tab. In Godot 4, GD.UnhandledException doesn't exist and methods subscribed to the alternative don't seem to be called.

Also, in Godot 3, the Unhandled Exception Policy setting gave users the option to terminate the application when an unhandled exception occurred, which I think makes the most sense. This setting is no longer present in Godot 4, and the application continues to run like nothing happened (at least in my limited testing, it appears to). Without being able to subscribe to an unhandled exception event of some kind, there's no way to close the application manually.

Unless I'm thinking about this the wrong way, I don't feel allowing the application to continue to execute in an invalid state is ideal. Are there any plans to reintroduce these features, or is there a good reason why they've been removed permanently I'm not seeing?

Steps to reproduce

N/A

Minimal reproduction project

N/A

RedworkDE commented 1 year ago

See also / Fixed by https://github.com/godotengine/godot/pull/68169

soccerob commented 12 months ago

See also / Fixed by #68169

It doesn't look like this fix was ever accepted, it's a pending PR at the moment with 1 issue during checks.

klootas commented 9 months ago

Any updates (or workarounds) on this? I'm trying to log runtime errors in-game. Thanks

hhyyrylainen commented 4 months ago

I tried using AppDomain.CurrentDomain.UnhandledException += ... but it seems it doesn't trigger, just the Godot's default print of the unhandled exception is triggered.

klootas commented 4 months ago

I tried using AppDomain.CurrentDomain.UnhandledException += ... but it seems it doesn't trigger, just the Godot's default print of the unhandled exception is triggered.

Yep, it's kind of bananas that this used to work but now no longer doesn't... The only reason I ever start the game from the Godot editor (which is SUPER slow compared to doing the same thing through the IDE) is to get a look at those pesky unhandled exceptions that we have no idea has happened until you actually run it from the Godot editor :P

hhyyrylainen commented 4 months ago

Does anyone know how I can get my debugger to break on unhandled exceptions? It seems that Godot 4 even prevents that. Surely that's not the way it's supposed to work? If there isn't an option I missed that would make that work, I guess I'll open a separate issue about that as that's going to make the debugging experience in Godot 4 absolutely miserable.

Avantir-Chaosfire commented 3 months ago

This is a really important issue. For me at least, crashes just freeze the game instead of terminating it, because the game can't keep running when unrecoverable errors occur, but it just... does... anyways? This is not helpful.

klootas commented 3 months ago

This is a really important issue. For me at least, crashes just freeze the game instead of terminating it, because the game can't keep running when unrecoverable errors occur, but it just... does... anyways? This is not helpful.

Yes, I have a feeling this one would be really high priority if only the right people would know about it - any info on whether this will be looked at for the 4.3 release?

Calinou commented 3 months ago

any info on whether this will be looked at for the 4.3 release?

4.3 is in feature freeze, so any new features will be for 4.4 at the earliest. To my knowledge, nobody is currently working on implementing this, so I don't know if a PR will be merged in time for 4.4.

I'm trying to log runtime errors in-game.

For this particular use case, https://github.com/godotengine/godot/pull/87576 will probably do the job. There's this caveat however (from the PR's description):

  • If the error is caused by a C# exception, and you're setting a callback in C#, then this doesn't provide access to the actual C# exception object. It could! I don't personally need this functionality but it's a pretty obvious thing to add later if there's demand.
AlexanderLangguth commented 3 days ago

Why was this still not prioritized? When a game server has an unhandled exception I need to be able to just hard crash to allow the program to be restarted. Now the program just either keeps on throwing exceptions, keeps on working with wrong data, or just plainly stops updating anything and is essentially just a zombie process.

AThousandShips commented 3 days ago

It's not being ignored, have you tested the PR that might solve this? Otherwise someone needs to make a solution for this, feel free to make one if you are able!

felipejfc commented 1 hour ago

I tested this one https://github.com/godotengine/godot/pull/91006 and it worked fine... I do have concerns about thread satefy part though