fix(session): launching the running game again resumes it instead of asking Steam twice (#2940)

* fix(session): launching the running game again resumes it instead of asking Steam twice

A front end that resumes a suspended player by launching the same game again
(Cocoon 3.07 does) made DroidDeck queue the game for Steam a second time,
and Steam answered with "An error occurred while launching this game: Game
already running" over the game.

queueSteamGame now resumes the session and returns when the requested game is
the current one and its process is running. A different game, or one that has
exited, still goes to Steam as before.

* fix(session): a relaunch during a pending freeze resumes too, and both game ID forms count as the same game
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-20 11:40:17 -05:00
1 parent d0022a35f9
commit 83dc5f37e9
3 files changed
+25

No files matched your search

@@ -1613,6 +1613,11 @@ class SessionService : Service() {
return
}
val accepted = gameId!!
if (pendingSteamGameId == null && SteamGameProcess.alreadyRunning(accepted, SessionState.gameId)) {
Log.i(TAG, "game $accepted is already running; resuming it instead of launching it again")
if (SessionState.suspended || SessionState.suspending) resumeSession()
return
}
if (!pendingSteamPreviousGamePending) {
pendingSteamPreviousGameId = SessionState.gameId
pendingSteamPreviousGamePending = true
@@ -61,4 +61,11 @@ object SteamGameProcess {
runCatching { File(p, "cmdline").readBytes() }
.getOrNull()?.let { matches(it, gameId) } == true
} == true
// A front end that resumes a player by launching the same game again would otherwise have Steam
// start it a second time, which Steam answers with "Game already running".
fun alreadyRunning(requested: String, current: String?, proc: File = File("/proc")): Boolean {
val appId = steamAppIdForGameId(requested) ?: return false
return appId == steamAppIdForGameId(current.orEmpty()) && running(requested, proc)
}
}