fix(session): sleep freezes the programs that run in worker processes (#3665)

With the native session, gamescope, Xwayland, wineserver and the game each run
in a worker process of their own: none descends from the session root, so the
freeze on sleep left them running. On wake the resume still added the frozen
time to the guest clock shift, and every one of them saw its monotonic clock
jump back by the length of the sleep. Unreal games abort on that:
KINGDOM HEARTS III failed with "Detected negative delta time" (DeltaTime
-10.05 s after a 13 s sleep).

The freeze now treats the session's worker programs as helper roots, as the
teardown already does.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-12-04 08:54:51 -05:00
1 parent 01c8991049
commit b61f766b66
1 file changed
+5 -1
@@ -945,11 +945,15 @@ class SessionService : Service() {
return
}
if (gen == sessionGen && SessionState.running) {
val workers = ownWorkers
suspendController = SessionSuspendController(
sessionRoot = { sessionPid },
// Programs handed off to worker processes are not descendants of the session root, and
// the clock shift applied at resume would move their monotonic time backwards.
helperRoots = {
components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } +
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 })
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) +
(if (workers > 0) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workers) else emptyList())
},
suspendAudio = {
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")