Skip to content

[Steam] Minor Shutdown Issue #656

Description

@peardox

This is rather trivial and NOT documented as a "do this" by Steam. Things work without this, they just work better with it.

I'm not suggesting this is needed, merely pointing it out (also I've not given it really thorough testing yet)

There exists what I'd guess is a resource leak in Steam. At startup it is required to get a handle to Steam Pipe...

SteamPipeHandle := SteamAPI_GetHSteamPipe();

This handle is however never released even though a mechanism exists to do so in SteamAPI_ISteamClient_BReleaseSteamPipe. Adding this to the current Destructor for Steam requires the definition of SteamAPI_ISteamClient_BReleaseSteamPipe of course. After this is done we get...

destructor TCastleSteam.Destroy;
begin
  FreeAndNil(FAchievements);
  if Enabled then
    begin
      SteamAPI_ISteamClient_BReleaseSteamPipe(SteamClient, SteamPipeHandle);
      SteamAPI_Shutdown();
    end;
  if ApplicationProperties(false) <> nil then
    ApplicationProperties(false).OnUpdate.Remove({$ifdef FPC}@{$endif} Update);
  inherited;
end;

I imagine that after Shutdown eventually the pipe goes stale and Steam discards it then on restart will create another.
One reason that you possibly wouldn't want to do this is if SteamAPI_RestartAppIfNecessary is called the pipe would be re-used (situation dependant - could flag it I guess).

The proof of this can be seen with the current Steam Demo (if this was added)...

[Without releasing pipe]
The effect of NOT releasing the pipe is subtle. Run the demo then close it and change the ID in steam_appid.txt - the demo will get confused and no Achievements will be displayed. If you shut down steam then restart it the demo will pick up the Achievements will be displayed as expected.

[Release pipe on close]
The demo should now not need Steam restarting in order to switch AppIDs as can be illustrated by changing the ID in steam_appid.txt - there is no confusion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions