0016: A GPU reset costs a few seconds, not the session
- Status: Accepted (owner, 2026-11-24, after a forced GPU reset on the host: the live device stream rebuilt its encoder and reconnected its capture, both Gamescope screens restarted, the TV home was back within 15 s). Proposed (my call, after the owner's "the gpu crash shouldn't have crashed entire session", 2026-11-15)
- Date: 2026-11-15
Context
On 2026-11-15 an N64 game made the GPU fault and reset. Everything that touched the GPU died: Gamescope on the TV and on the handheld's screen, ES-DE with it, and our server, which took every client's stream down. Mesa's amdgpu winsys calls abort() on a reset for any context created without PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET (amdgpu_ctx_set_sw_reset_status), and its VA-API frontend never asks for that flag, so an in-process VAAPI encoder cannot survive a reset whatever the server does. Sunshine and Wolf encode in their own process and share that fate.
Decision
- The server encodes video in a child process (
couchdogs-server encode-helper,src/encode_process.*), fed frames over a socket pair. A dead, hung (2 s per frame) or failing helper is killed and built again 1 s later, and the next frame is an IDR; ten failures in a row end the stream. - A capture whose PipeWire daemon went away is reopened: the stream asks the runner for its screen again (which starts a stopped screen container) and reconnects, repeating the last picture meanwhile; after 60 s it gives up.
- The runner reopens the app that was in front when a screen restart took it away (seen as the app gone while the screen is down or answers with no baselayer, or within 30 s of a fresh one; an xprop that fails is no answer), at the app's own start (ES-DE's menu, never the game), once per app per 10 minutes, and only if the player has not picked something else meanwhile (checked again under the launch lock). An app still running when a fresh screen comes up (one that did not die with Gamescope, as Plex did not on 2026-11-16, leaving a black screen) is stopped first, then reopened the same way; an app launched onto that fresh screen is left alone.
Consequences
- A reset still shows a frozen picture for a few seconds and loses the running game; the client stays connected.
- One extra copy of each frame over a socket (well under a millisecond at 1080p).
- A device that leaves or cancels during a screen's reopen is let go at once; the screen worker waits for the stream's threads before it releases the screen.
- Every loss is recovered, not only the first (a recovery counter, not a "capture waiting" flag), and a screen lost again soon after waits a retry delay first.
- A helper that does not die on SIGKILL (stuck in the driver) is reaped on a side thread; a helper whose server died gets SIGKILL from the kernel.
- Not verified on a real reset yet: tests kill the helper and drop the captures.