Skip to content

Survive the Ultimate going away: quick exit, stream-lost screen - #23

Merged
crustovsky merged 3 commits into
mainfrom
poweroff-exit
Sep 3, 2026
Merged

crustovsky merged 3 commits into
mainfrom
poweroff-exit

Conversation

@crustovsky

Copy link
Copy Markdown
Owner

What

Switching the Ultimate off with the viewer running looked like a freeze followed by a crash. Root cause: the stream view kept the last frame with no hint, and Ctrl+Q then joined the keepalive thread through up to 13 s of REST timeouts without pumping events, which is longer than Hyprland's "Application Not Responding" threshold (about 8 s). The process then exited on its own. There was no crash: no coredump, and the journal shows the normal D-Bus screensaver un-inhibit right before the scope ended.

Changes

  • Keepalive REST calls are cancellable (curl xferinfo callback on g_quit) and get a 1.5 s connect timeout, because the callback does not run while a SYN goes unanswered. The stop calls at exit are skipped when the last start got no answer, and bounded to 1 s otherwise.
  • The exit path pumps SDL events until the background threads report done, then joins them. No more unanswered compositor pings.
  • After 2 s without a frame the status screen shows "no stream from , is the Ultimate powered on? waiting..."; the stream view comes back by itself with the next frame.
  • Sockets are SOCK_CLOEXEC, so the ping spawned for the ARP prime stops inheriting the viewer's connections.
  • New integration test: a tarpit server stands in for a dead machine; SIGTERM must end the viewer within 3 s. The old binary takes 7 s in that test.
  • CLAUDE.md documents the hermetic reproduction (user+net namespaces, veth, ip addr del on the far end, Hyprland send_shortcut for keys).

Verified

  • make test and tests/integration.sh pass.
  • Namespace lab on a Wayland desktop: fake vanished while in the F9 view, keys pressed in both views, quit took 0.1 to 1.5 s and the ANR dialog no longer appears (it appeared at +8.2 s before, exit at +11.5 s). Stream-lost screen rendered and checked visually; stream resumes after the fake returns.
  • Still to confirm on real hardware: power-cycle in the stream view, help overlay, and during a drop.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GCACXGV72EjRZUUKapybmQ

crustovsky and others added 3 commits September 3, 2026 21:48
Powering the Ultimate off with the viewer running looked like a freeze
followed by a crash. It was neither: the stream view kept the last frame
with no hint, and Ctrl+Q then joined the keepalive thread through up to
13 s of REST timeouts without pumping events, long enough for Hyprland's
"Application Not Responding" dialog before the process finished on its
own (no coredump; the D-Bus screensaver un-inhibit shows a normal exit).

- Keepalive REST calls take a cancel flag (curl xferinfo callback on
  g_quit) plus a 1.5 s connect timeout, since the callback does not run
  while a SYN goes unanswered. The stop calls at exit are skipped when the
  last start got no answer and bounded to 1 s otherwise.
- The exit path keeps pumping SDL events until the discovery and
  keepalive threads report done, then joins them.
- After 2 s without a frame the status screen says "no stream from
  <host>" instead of leaving the last picture standing; the stream view
  returns by itself with the next frame.
- Sockets are opened SOCK_CLOEXEC so the ping spawned for the ARP prime
  no longer inherits the viewer's connections.
- Integration test: a tarpit server (accepts, never answers) stands in
  for a dead machine; SIGTERM must end the viewer within 3 s (the old
  binary took 7 s). Reproduction recipe for a vanishing host (user+net
  namespaces, veth, ip addr del) documented in CLAUDE.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GCACXGV72EjRZUUKapybmQ
Found on hardware after the power-off fix: F9 with the Ultimate off
entered the menu view anyway, which rendered the terminal's empty black
grid (a "black square"), and a machine switched off while the menu view
was open kept its last screen up as if it were live, since a silent
power-off never closes the telnet link.

- F9 enters the menu view only on a live connection; otherwise a 3 s
  notice on the status screen says the menu is unreachable (powered
  off? telnet enabled?) and the previous view comes back.
- A menu connection that closes or fails to send drops the view with a
  "connection lost, F9 reconnects" notice.
- Stream loss closes the menu link and leaves the view: the "no stream"
  screen replaces the stale menu; F9 reconnects once the machine is back.
- Notices restore the stream-lost or waiting text when they expire.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GCACXGV72EjRZUUKapybmQ
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GCACXGV72EjRZUUKapybmQ
@crustovsky
crustovsky merged commit b8b6ae8 into main Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant