Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Steam never understands when my game shuts down

Discussion in 'General Discussion' started by Demigiant, Dec 17, 2014.

  1. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    I've had this problem for years while developing our game.

    However, I've just looked into it a bit more, and have some info.

    You can enable the Steam Client 'Console' to help with this. If you put the switch '-console' in the command line of the Steam client. So, change the Target to: "C:\Program Files (x86)\Steam\Steam.exe" -console

    Then when Steam starts, there is now an extra tab at the top called 'CONSOLE'.

    In here is a command called apps_running. If you run that, now every time Unity starts the game (with the .Init()) it will log its PID and then all the other child PIDs that connect as time goes on. Then at the very least you can check through that list to see which PID it is that could still be running. Mostly for me its 'VBCSCompiler.exe' or 'sgdm.exe' (DiffMerge for Collab)

    There is also a app_stop <appid> command that will force the app to stop, but this will kill the Unity editor, or any other child PID that is running.

    Unfortunately, it doesn't work that well. If you haven't started app_running before you have the problem, then even though there is a field called 'associated PIDs, it doesn't seem to be updated with any child PIDs, so you can see them. So you have to make sure you start that command as you start the game/Unity.

    I've just written a support request to Steamworks about this, and asked if they can 'fix' the associated field, to list all PIDs they are still waiting on.

    I've also asked if there is some kind of change they can make to help developers. Either some SteamAPI.SetAppRunning = false; or something we can run within a '#if UNITY_EDITOR' in OnDestroy along with the shutdown or, some new Steam Client console command that will 'clear' the running flag. A bit like the 'app_stop' command, but just to clear the flag rather than kill the process. Then we can continue to use the Editor without a restart.

    Hopefully they respond favourably to the request and it might just help developers a little when running and testing games within Unity and the Steam Client.
     
    Ony, zzzz789, MihaPro_CarX and 2 others like this.
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,306
    Awesome, thank you! This is very useful info!

    What I have started doing is not even initializing Steamworks anymore unless I'm actively working on something that requires it. The reason I do this is because I don't want Steam to count my development time as play time (and logging in with another account would be too much hassle for me, so I only do this when I have to).
     
  3. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Are you saying I havent played my own game this much? :p

    upload_2021-2-17_13-42-1.png
     
    jashan likes this.
  4. TeeArr

    TeeArr

    Joined:
    Jul 19, 2019
    Posts:
    10
    I wan to open a .pdf file from within my game. This leads to the same problem as Steam then thinks that whatever program is displaying the pdf is part of the game.
    Is there any work-around to start a process or in this case show a PDF file that doesn't spawn a child procees or something?
     
  5. TeeArr

    TeeArr

    Joined:
    Jul 19, 2019
    Posts:
    10
    Ok, I've found a solution. I now open the PDF file in the Steam Overlay Browser instead. This way no new process is started and gets in the way of closing the game for Steam correctly.