ALT+F4 make my game freeze

Hello everyone,

I encounter an issue I don’t know how to find what’s happen : On the main menu of my game, I have a button that close my game or I hit ALT+F4 and the game closes. But when I’m playing, if I hit ALT+F4 my game freezes, a Windows pop-up appears to force the game to close. I can repoduce this issue everyTime.

But I don’t know what to to do to identify why it is doing that ?

On character selection scene, same issue as when playing, ALT+F4 causes the game to freeze …

On setting menu scene or Online Score scene or main menu, ALT+F4 closes the game normaly.

If I play a game a return to the menu, and press ALT+F4 or click on quit button, this make the game freeze again but if I don’t play a game and press ALT+F4 or click on quit button my game doesn’t freeze.

All of that happens on the builded game, not editor.

I’ve checked on the logs and the only difference in log when the game freeze and when it is not are those lines :
“Curl error 42: Callback aborted
Curl error 42: Callback aborted



Curl error 42: Callback aborted
Curl error 23: Callback aborted



Curl error 42: Callback aborted Curl error limit reached: 100 consecutive messages printed”

But when you look at the causes of curl 42 on the internet, you can see that it’s linked to problems communicating with a server, but other scenes in my game also use commands to communicate with a server, but in these scenes ALT+F4 doesn’t crash the game, so I’m not sure that’s the cause of my problem.

When the game freeze, if I wait 30 sec, the game unfreeze itself and closes

Could you recommand some advice to identify why ALT+F4 freezes my game ?

There‘s probably something that runs for an extended time when the app closes. This could be garbage collection, resource unloading or your own code depending on what executes when the game shuts down.

Since this occurs only in a build, make a development build and attach the debugger, then set a breakpoint in the method that initiates the shutdown. You can also attach the Profiler and add Debug Logs and breakpoints to potentially time consuming shutdown code in OnDisable, OnDestroy, OnApplicationQuit and so on.

Essentially: debug it, there is no other way.

Thanks for the quick answer.

But I don’t know the method that initiates the shutdown and well, I’ve got a lot of script to test and that’s why I’ve come here to ask for help in getting a clue as to what might be causing the problem rather than testing all my scripts.

So now, I’ll start with OnDisable, OnDestroy and OnApplicationQuit. But the thing is that OnApplicationQuit isn’t called by any of my scritps. I don’t expect the player to press ALT+F4 in the middle of the game. Should I?

You don‘t callOnApplicationQuit. Unity calls it on every script that implements it (as well as OnDisable and OnDestroy) when the game shuts down.

We can‘t help by providing wild guesses, since we don‘t have your project and the issue could be anything but is most definitely unique to your project.

You could show some code that you suspect to be causing the issue but first you‘d have to narrow it down to that method (if any). The profiler may also reveal some insight, possibly more than anything else but I‘m not certain if it still logs upon shutdown.

1 Like

Yes I understand

I’ll attach Profiler and Debugger to see it something is weird in their graph and see if it can help me to solve the issue.

I’m coming back with the reult graphs

Thanks a lot CodeSmile