fix(client/linux): let a forwarding instance exit #2255

Merged
enricobuehler merged 1 commits from fix/client-linux-forwarded-exit into main 2026-11-01 18:09:06 +00:00
Owner

A second punktfunk-client, launched by a link or a desktop shortcut, handed off to the running client and then never exited. Each click left a stuck process holding an SDL gamepad service. Streaming from several hosts (#2250) makes that path much more common.

Cause

gdb on the stuck process: the main thread sits in relm4::RelmApp::run, in MainContext::iteration(true) (relm4-0.11.0/src/app.rs:199). g_application_run has already returned by then, and a remote instance has no source that could fire.

Fix

Before app.run::<AppModel>, an idle arms a 50 ms timeout. The idle runs in GApplication's final drain and leaves a timer that is not ready yet, so relm4's blocking iteration has something to wake it.

Rejected

  • A plain idle. g_application_run ends with while (g_main_context_iteration(context, FALSE));, which drains every ready source first. That build hung: exit 124 in 3 of 3 runs.
  • adw_app.register() before RelmApp::run. relm4 builds the window in connect_startup.

Measured

In the pf-client-check image under Xvfb, with the real shell:

Case Second instance
link, shell idle exits 0 in about 110 ms
link, stream running exits 0 in about 110 ms
bare launch exits 0 in about 110 ms

The link still reaches the primary, the primary still quits normally, and the shell's 34 tests pass. Not checked on a real desktop session.

A second `punktfunk-client`, launched by a link or a desktop shortcut, handed off to the running client and then never exited. Each click left a stuck process holding an SDL gamepad service. Streaming from several hosts (#2250) makes that path much more common. ## Cause gdb on the stuck process: the main thread sits in `relm4::RelmApp::run`, in `MainContext::iteration(true)` (`relm4-0.11.0/src/app.rs:199`). `g_application_run` has already returned by then, and a remote instance has no source that could fire. ## Fix Before `app.run::<AppModel>`, an idle arms a 50 ms timeout. The idle runs in GApplication's final drain and leaves a timer that is not ready yet, so relm4's blocking iteration has something to wake it. ## Rejected - A plain idle. `g_application_run` ends with `while (g_main_context_iteration(context, FALSE));`, which drains every ready source first. That build hung: exit 124 in 3 of 3 runs. - `adw_app.register()` before `RelmApp::run`. relm4 builds the window in `connect_startup`. ## Measured In the `pf-client-check` image under Xvfb, with the real shell: | Case | Second instance | | --- | --- | | link, shell idle | exits 0 in about 110 ms | | link, stream running | exits 0 in about 110 ms | | bare launch | exits 0 in about 110 ms | The link still reaches the primary, the primary still quits normally, and the shell's 34 tests pass. Not checked on a real desktop session.
enricobuehler added 1 commit 2026-11-01 17:49:23 +00:00
fix(client/linux): let a forwarding instance exit
ci / changes (pull_request) Successful in 19s
ci / web (pull_request) Skipped
ci / docs-site (pull_request) Skipped
ci / sdk-plugin-kit (pull_request) Skipped
ci / decky-typecheck (pull_request) Skipped
ci / bun-nix (pull_request) Successful in 27s
secret-scan / gitleaks (pull_request) Successful in 28s
ci / docs-drift (pull_request) Successful in 36s
ci / rust-arm64 (pull_request) Successful in 8m58s
ci / rust (pull_request) Successful in 18m52s
2630cbf727
A second launch hands its link or activation to the running client, then
never exits. relm4 ends `run` on a blocking main-context iteration, and
GApplication has already drained every ready source by then, so nothing
wakes it. Each shortcut click left a stuck process with a gamepad service.

An idle runs in that drain and leaves a timer for the iteration.
enricobuehler merged commit 435b73e3f2 into main 2026-11-01 18:09:06 +00:00
enricobuehler deleted branch fix/client-linux-forwarded-exit 2026-11-01 18:09:08 +00:00
Sign in to join this conversation.