A replaced session's exit no longer ends the one that replaced it

Hand-off from the desktop: the new session started, and a second later the old proot - killed
by its own teardown - reported its exit, which the service took as the current session ending
("The session ended 137"). Exits are matched to the session that started the process. The same
race took the new session's log capture and its folder (stopFor / release by folder), and a
finishing activity unhooked the replacement's end listener (compared by identity now).
This commit is contained in:
The412Banner committed 2026-09-22 11:15:35 -04:00
1 parent 593ef8fcaf
commit 74b4c2ef09
4 files changed
+34 -7

No files matched your search

@@ -234,7 +234,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
hud.start()
}
}
SessionState.endListener = { status -> onSessionEnded(status) }
SessionState.endListener = endListener
// Back opens the drawer (and closes it again). Leaving the session running in the
// background and ending it are both actions in there, so neither can happen by accident
// from a button a game might also be reading.
@@ -724,13 +724,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
}
/** Ours, so a finishing activity never unhooks the one that replaced it. */
private val endListener: (Int) -> Unit = { status -> onSessionEnded(status) }
override fun onDestroy() {
// Deliberately does NOT end the session: this activity can be destroyed while the user is
// in another app, and the whole point of the service is that Steam survives that.
watching = false
if (::hud.isInitialized) hud.stop()
padBridge?.stop()
SessionState.endListener = null
if (SessionState.endListener === endListener) SessionState.endListener = null
WaylandCompositor.setFirstFrameListener(null)
super.onDestroy()
}