Skip to content

Stage an owned queue as a macOS or Linux session ends - #971

Merged
SimonCropp merged 2 commits into
mainfrom
session-end-linux
Oct 23, 2026
Merged

SimonCropp merged 2 commits into
mainfrom
session-end-linux

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

A viewer that owns the inline queue holds it in memory and stages it on the way out, but a Linux logoff never gets that far:

  • The X server goes first, and Xlib then ends the process with exit(1).
  • systemd sends SIGTERM and SIGHUP, and .NET ends the process on either with no finally run.

Either way the snapshots were lost. Windows already staged them, through HeadForm.SessionEnding.

This moves to PlatformHeads 0.6.0 (SimonCropp/PlatformHeads#3), which hears both:

  • ViewerProgram.SessionEnding marks the session closing and stages the queue. It runs once and touches no window, so it's safe on a signal's thread or inside a call into the window. A display lost during a mutation can't mark the session closing, but the queue is still staged.
  • NativeViewerWindow implements ILoopHooks and passes SessionEnding to the new deview_on_display_lost. The Linux shim hands it to ph::OnDisplayLost. The macOS shim exports it and never calls it, because a logout there is the app's own quit.
  • ViewerProgram holds a SessionEndSignals for SIGTERM and SIGHUP. Signals don't save the placement, since they arrive on a thread of their own. The Windows hook still saves it after staging.
  • DEVIEW_VERSION goes to 13 for the new entry point, and all six PlatformHeads pins move to 0.6.0.

Checked in an ubuntu:24.04 container by building the shim at 0.6.0, then running the viewer under Xvfb, launched with an inline payload for a temporary project:

  • Killing Xvfb: the trio was staged in obj/VerifyInline, then Xlib exited with code 1.
  • SIGTERM, then SIGHUP at once: the trio was staged, and the exit code was 129.

ViewerProgramTests checks that SessionEnding stages the queue, does so from inside a mutation, and stages it only once.

The committed binaries are still version 12, so the native jobs fail until the binaries PR that build-native opens is merged into this branch.

SimonCropp and others added 2 commits October 23, 2026 17:50
An owning viewer's queue lives in its memory and is staged on the way out, which a Linux logoff
never reaches. The X server goes first, and Xlib then ends the process with exit(1); systemd
sends SIGTERM and SIGHUP, on which .NET ends it with no finally run. The snapshots went with it.

ViewerProgram.SessionEnding stages the queue once and touches no window, and is heard both ways
through PlatformHeads 0.6.0: deview_on_display_lost (ph::OnDisplayLost), which NativeViewerWindow
takes as ILoopHooks.SessionEnding, and SessionEndSignals, held by ViewerProgram. The Windows hook
still saves the placement after it. DEVIEW_VERSION is 13 for the new entry point, which the macOS
shim exports and never calls: a logout's quit there is the app's own.
Co-authored-by: SimonCropp <122666+SimonCropp@users.noreply.github.com>
@SimonCropp
SimonCropp merged commit f1d520c into main Oct 23, 2026
15 checks passed
@SimonCropp
SimonCropp deleted the session-end-linux branch October 23, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant