rlabrecque / Steamworks.NET

Steamworks wrapper for Unity / C#
http://steamworks.github.io
MIT License
2.81k stars 368 forks source link

Shutting down (or restarting) the Steam launcher while the game is running causes SteamAPI.RunCallbacks() to permanently freeze the game/program #550

Open Shyryp opened 1 year ago

Shyryp commented 1 year ago

Shutting down (or restarting) the Steam launcher while the game is running causes SteamAPI.RunCallbacks() to permanently freeze the game/program.

I give an example: 1) Launch Steam. 2) Run the game, where SteamAPI.RunCallbacks() is and is called (I have this function called every frame). 3) Force close Steam (for example, through the Task Manager). 4) The game will freeze on the SteamAPI.RunCallbacks() function and never return (unless you have a "SteamAPI.IsSteamRunning()" check before calling "SteamAPI.RunCallbacks()").

If you add a "SteamAPI.IsSteamRunning()" check, then "SteamAPI.RunCallbacks()" will not be called until after the Steam Launcher is launched. However, when "SteamAPI.RunCallbacks()" is called while Steam is already running, RunCallbacks will never return and freeze the game.

Example of my code:

if (steamInitialized_ && (SteamAPI.GetHSteamPipe() != (HSteamPipe)0) && SteamAPI.IsSteamRunning())
{
      SteamAPI.RunCallbacks();
}

Of course, under normal conditions, if Steam is working properly, users will not receive such an error, since when Steam is closed, the game itself is also closed. But, if it happens that Steam crashes (and reboots itself, if you use for check IsSteamRunning()), there is a chance that the game will freeze on the next call to SteamAPI.RunCallbacks().

P.s. At the same time, if you first start the game, and then the Steam Launcher, then RunCallbacks work out normally and do not freeze the game.

Shyryp commented 1 year ago

Additional note: If all callbacks in the program/game are commented out or disabled, then SteamAPI.RunCallbacks() still freezes the program/game.