docs: gamerig kiosk revisited on Xorg: Chandra as an X client, go
CI / test (push) Successful in 2m38s

Chandra runs as gamerig's library window on its NVIDIA Xorg; games, Selkies
and server.py stay as they are, so dmabuf/Xwayland are no longer needed. Gap
list, size (Chandra package 12 MiB gz measured), staged plan, test status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
This commit is contained in:
Claude committed 2026-11-26 02:24:36 +00:00
1 parent d521d0d840
commit 81cb8f9a1c
1 file changed
+112 -181
+112 -181
View File
@@ -3,212 +3,143 @@
Question (V, 2026-11-26): gamerig, the game streaming platform Question (V, 2026-11-26): gamerig, the game streaming platform
(<https://git.site.latha.org/experiments/gamerig>), could use Chandra instead of its current (<https://git.site.latha.org/experiments/gamerig>), could use Chandra instead of its current
display/session shell, "because it's so small". This document says what that shell does today, display/session shell, "because it's so small". This document says what that shell does today,
what Chandra has, what is missing, and in what order to close the gaps. Numbers marked **measured** how Chandra fits, what is missing, and in what order to close the gaps. Numbers marked
were measured for this document; **est.** are estimates with the method given. **measured** were measured; **est.** are estimates with the method given.
**Revised 2026-11-26** after Chandra gained its X11 backend (`--x11`, e6be382/e184e29,
[x11.md](x11.md), tested on a Vast GTX 1650 with driver 595 under gamerig-tiny's Xorg) and kiosk
mode (`--kiosk`, d521d0d, [kiosk.md](kiosk.md)). The first version of this document assumed Chandra
had to replace Xorg as a Wayland compositor, which needs linux-dmabuf, Xwayland and a Wayland port
of Selkies; its verdict was "not yet". On Xorg none of that is needed.
## TL;DR ## TL;DR
* **gamerig has no client device.** A rig is a headless Docker container on a rented Vast.ai NVIDIA * **gamerig has no client device.** A rig is a headless Docker container on a rented Vast.ai NVIDIA
host. Games run *inside the container*, NVIDIA Xorg is the screen, Selkies-GStreamer captures it host. Games run inside it on headless NVIDIA Xorg; Selkies-GStreamer captures the X screen
(`ximagesrc`), encodes it with NVENC and sends it over WebRTC to the player's **browser**. The (`ximagesrc`), encodes it with NVENC and sends it over WebRTC to the player's browser. The
"kiosk" is the in-stream home screen: Openbox + a fullscreen watcher + a WebKit2GTK window showing "kiosk" is the in-stream home screen: Openbox, a fullscreen watcher, a WebKit2GTK window showing
the library UI + a GTK taskbar. Chandra would replace that stack, and ideally Xorg too, *on the rig*. the library (`shell_window.py`) and a GTK taskbar.
* **Chandra can't do that today, and the reason is not the shell.** The shell side (fullscreen * **Chandra now fits as an X client on that Xorg.** Xorg, the NVIDIA driver, Selkies, server.py and
single-app policy, no panel, locked shortcuts, a launcher as a module) is small work. The blockers the games stay exactly as they are. Chandra replaces the library window: one fullscreen X window
are the display-server plumbing a streaming rig needs: with `WM_CLASS gamerig-desktop` (so Openbox's rules, Ctrl+Alt+L / Super+Space and server.py's
1. **Games can't present to Chandra with the GPU.** NVIDIA's Vulkan/EGL Wayland WSI needs `wmctrl -xa` find it as before), running in kiosk mode inside.
`zwp_linux_dmabuf_v1`; Chandra only has `wl_shm`. Without it a game either fails (the tiny * **Games keep the GPU.** They are X11 (or SDL on X11) clients of NVIDIA Xorg, started by server.py,
image has no Mesa software Vulkan) or runs on lavapipe/llvmpipe, which is unplayable. This not by Chandra, so the dmabuf problem never comes up. Steam and Proton are X11 anyway.
project already saw it with Zed/Delta falling back to llvmpipe. * **Selkies keeps working unchanged**: it captures the X screen Chandra draws into (MIT-SHM),
2. **Steam (and Proton games by default) are X11 clients.** Chandra has no Xwayland/XWM. injects keyboard and mouse with XTest (Chandra reads them as ordinary X events; tested with
3. **Selkies 1.6.2 is X11-only**: capture is `ximagesrc`, keyboard/mouse injection is XTest, `xdotool` on NVIDIA), and resizes with `xrandr` (Chandra follows).
resize is `xrandr`, clipboard is `xsel`. A Wayland compositor needs a new capture source, an * **Step 1 is built**: `--kiosk CMD` (no panel, no shortcuts or desktop menus, the app fullscreen,
input-injection path, resize and clipboard hooks. restarted when it exits, Ctrl+Alt+Shift+Escape or `chandra-ctl kiosk unlock` for admin work),
4. **No frame export or frame pacing for an encoder.** Headless Chandra renders into a CPU `--app-id NAME`, and `scripts/gamerig-kiosk.sh`, which swaps gamerig's library window for Chandra
framebuffer at a fixed ~60 Hz loop and only writes PNGs; frame callbacks fire on commit. on a running rig. Tested locally under Openbox on Xvfb (fullscreen, `WM_CLASS`, XTest typing,
* **The size win is real but modest.** Chandra itself is ≈ 12-18 MiB compressed est. restart). **Not yet tested on a rig** (see §6).
(`libwasmtime.so` 8.4 MiB gz **measured**, fonts 4.7 MB raw, components and small libs). It would * **The size win comes in steps 2 and 3**, not step 1. Chandra is **12 MiB gzip measured** (the
remove Openbox (≈ 52 MiB est.), the WebKit2GTK kiosk (≈ 67 MiB est.) and maybe Xorg core, but GPU whole package: host with wasmtime linked in, compositor, modules, fonts, the few libs a tiny
buffer import brings `libgbm`/EGL back, and Xwayland brings part of the X stack back. Expect image lacks). Step 1 adds it next to WebKit. Step 2 (a native launcher module) removes the
**≈ 100-120 MiB saved out of the ≈ 450 MiB `gamerig-tiny` image (est.)**. gamerig's own plan WebKit kiosk (≈ 67 MiB est.); step 3 (Chandra as the X window manager) removes Openbox
(`docs/tiny-image/DESIGN.md` M3: a MoonBit X11 WM plus a browser-side library) gets most of that (≈ 52 MiB est.). Net ≈ **−105 MiB** of the ≈ 450 MiB `gamerig-tiny` image (est.).
win with much less risk. * **Recommendation: go**, with two caveats: confirm step 1 on a rig first, and the real work is the
* **Recommendation: not yet as a replacement for the rig's display stack. Go with caveats on a launcher module (step 2), since Chandra can't render the HTML/Rabbita library itself.
staged path that starts with a go/no-go spike** (does an NVIDIA game present a dmabuf to Chandra
inside a Vast container, and can that frame reach NVENC?). If the spike fails, Chandra is still a
good fit for a *physical* kiosk box (reading B below), which works with today's Chandra plus a
`--kiosk` profile.
## Two readings of "kiosk for gamerig"
| | A. Rig-side shell (what gamerig runs today) | B. A physical thin-client box |
| --- | --- | --- |
| Where Chandra runs | inside the Vast container, headless, no monitor, no input devices | a mini PC / TV box on the player's desk, on DRM/KMS |
| What it shows | the library, then the game, captured and streamed | a browser, fullscreen, on gamerig's play page |
| Who renders the game | the rig's NVIDIA GPU, presenting to Chandra | nobody locally: the browser decodes the WebRTC video |
| Fit with Chandra today | poor (gaps 1-4 above) | good: needs a kiosk profile; video decode is the browser's job |
The rest of this document is about **A**, because that is what "it's using gamerig right now"
replaces. **B** is covered in its own section at the end.
## 1. What gamerig's session shell does today ## 1. What gamerig's session shell does today
Read from `docker/onstart.sh` (3,758 lines), `docker/desktop/*.py`, `desktop/ui/`, `docker/Dockerfile.tiny` Read from `docker/onstart.sh`, `docker/desktop/*.py`, `desktop/ui/`, `docker/Dockerfile.tiny` and
and `docs/tiny-image/DESIGN.md` in the gamerig repo (commit 375ac7e). `docs/tiny-image/DESIGN.md` in the gamerig repo.
| Piece | Today | Kiosk duty a replacement must cover | | Piece | Today | With Chandra |
| --- | --- | --- | | --- | --- | --- |
| Display server | headless **NVIDIA Xorg `:0`**, a 4-variant xorg.conf retry ladder, NV-GLX verification, `GAMERIG_FATAL=` codes the control plane parses (`docs/xorg-modeset.md`) | a screen whose GPU-rendered content is capturable; same failure reporting | | Display server | headless **NVIDIA Xorg**, 4-variant xorg.conf retry ladder, `GAMERIG_FATAL=` codes | unchanged |
| Window manager | **Openbox** with a generated `rc.xml`: games borderless and maximized, dialogs (Steam login, file pickers) left alone; **Ctrl+Alt+L** / **Super+Space** back to the library, **Alt+Tab** to switch | single-app fullscreen policy that still lets dialogs float; 2-3 fixed shortcuts | | Window manager | **Openbox** with a generated `rc.xml`: every normal window borderless fullscreen, `gamerig-desktop` too; Ctrl+Alt+L / Super+Space run `wmctrl -xa gamerig-desktop`; Alt+Tab | step 1: unchanged. Step 3: Chandra manages X windows itself |
| Fullscreen watcher | Python + python-xlib loop in onstart (`start_fullscreen_watcher`) keeping game windows snapped fullscreen, skipping dock windows | the compositor does this itself | | Fullscreen watcher | python-xlib loop keeping games snapped to the screen after resizes | step 3: Chandra |
| Home screen | `shell_window.py`: GTK3 + **WebKit2GTK** fullscreen window (`WM_CLASS gamerig-desktop`), can't be closed, restarted by a supervisor with backoff and a `--safe` mode | an always-there home surface, restarted if it dies | | Home screen | `shell_window.py`: GTK3 + **WebKit2GTK** fullscreen X window (`gamerig-desktop`), restarted by a bash supervisor | step 1: Chandra's X window (`--app-id gamerig-desktop`), kiosk mode; inside it, the same `shell_window.py` as a Wayland client. Step 2: a native module |
| Library UI | `desktop/ui`: MoonBit + Rabbita (calm) web app: categories, searchable grid, Launch / Big Picture / Focus / Logs / Stop, Add App, Running apps, Rig status (GPU, display, audio), dark/light | the launcher module's content | | Library UI | `desktop/ui`: MoonBit + Rabbita (calm) web app: categories, search, app grid, Launch / Big Picture / Focus / Logs / Stop, Add App, running apps, rig status | step 2: ported to a Chandra desktop module |
| Library daemon | `server.py` (Python stdlib, `127.0.0.1:8091`): catalog, launch apps in their own process group, focus/stop via `wmctrl`/`xdotool`, logs | unchanged, but focus/stop must talk to the compositor instead of X | | Library daemon | `server.py` on `127.0.0.1:8091`: catalog, launches apps as X11 clients, focus/stop via `wmctrl`/`xdotool` | unchanged |
| Taskbar | `taskbar.py`: GTK dock bar, Library button + a button per window (`wmctrl -l -x`) | a minimal task strip, or Alt+Tab only | | Taskbar | `taskbar.py` (GTK dock bar via `wmctrl -l`) | unchanged; later Chandra's own task strip |
| Streaming | Selkies-GStreamer 1.6.2 (Python): `ximagesrc` → `cudaupload ! cudaconvert` → `nvh264enc` → `webrtcbin`; audio `pulsesrc` → `opusenc`; signalling on `:8080`; ICE wrapper pinned to Vast's UDP ports | capture source, encoder-paced frames | | Streaming, input, resize | Selkies 1.6.2: `ximagesrc`, XTest, `xrandr`; gamepads as uinput devices read by games | unchanged |
| Input | keyboard/mouse from the WebRTC data channel injected with **XTest** (python-xlib, pynput); **gamepads as uinput devices** (`/dev/uinput` chmod'ed by onstart) | key/pointer injection into the compositor; gamepads go to games directly | | Audio | PipeWire + pipewire-pulse | unchanged |
| Resize / clipboard | `xrandr` resize to the browser's size (with a resize probe and fallback); `xsel` clipboard | output resize and clipboard hooks | | Auth, updates, networking | on the control plane / in the image / Docker | nothing for Chandra to do |
| Audio | PipeWire + pipewire-pulse (PulseAudio fallback), `/tmp/pulse-socket` | none from the compositor |
| Boot | `onstart.sh` is PID 1: D-Bus, audio, Xorg, WM, probes, Selkies supervisor, library; `[gamerig-boot]` timing line and `Ready in Ns` | keep the log contract |
| Auth, login, updates, Wi-Fi | not on the rig: Zitadel OIDC / ATProto on the control plane; the image *is* the update; networking is Docker's (Tailscale optional) | nothing |
| Display modes / HDR | resolution = the stream (xrandr resize); refresh = Selkies `--framerate`; H.264 8-bit SDR, so no HDR anywhere | output size control; HDR irrelevant |
Apps the catalog runs: **Astra** (SDL3 + wgpu, Vulkan, GL fallback), **Steam** (32-bit X11 client, ## 2. How the pieces fit on one Xorg
Big Picture), Lutris/Heroic, `vkcube`, `xterm`, `pavucontrol`, a WebKit browser window, the Roblox
(MoonBit, GTK4) launcher.
## 2. What Chandra has ```
NVIDIA Xorg :0 ─────────────── Selkies (ximagesrc → NVENC → WebRTC; XTest input; xrandr)
├─ Openbox (step 3: Chandra)
├─ Chandra --x11 --fullscreen --app-id gamerig-desktop --kiosk "<library app>"
│ └─ Wayland clients on Chandra's socket: the library app (WebKit today, a module later)
├─ games, Steam, Proton, xterm … X11 clients started by server.py, full NVIDIA GLX/Vulkan
└─ taskbar.py
```
From `main` at 42aa770. * **Back to the library**: Ctrl+Alt+L is an Openbox binding (`wmctrl -xa gamerig-desktop`), so it
raises Chandra's window over the game; server.py's "focus library" does the same. Nothing changes.
| Area | Status | * **Launching a game** from the library calls server.py, which starts it on Xorg; Openbox maps it
| --- | --- | fullscreen above Chandra. Chandra keeps its last frame and goes idle (it only draws when its
| Protocols | `wl_compositor`, `wl_subcompositor` (subsurfaces accepted, not composited), `wl_shm`, `xdg_wm_base` (toplevels, popups), `zxdg_decoration_manager_v1`, `wl_data_device_manager`, `wl_seat`, `wl_output`, `wp_cursor_shape_manager_v1`. **No** `linux-dmabuf`, viewporter, fractional scale, presentation-time, virtual keyboard/pointer, data-control, screencopy, layer-shell, Xwayland. | content changes).
| Rendering | CPU rasteriser in the host; composes the scene into a CPU framebuffer. Fixed ~60 Hz loop when busy, idle sleep otherwise. Frame callbacks fire on commit (no pacing). | * **Environment**: Chandra starts its kiosk app with `WAYLAND_DISPLAY` set and `DISPLAY` unset. Games
| Backends | `--window` (nested on a Wayland session), `--drm` (KMS + libinput via libseat; page flips, damage-limited), and **headless** (no flag: renders, `--gfx-out --serve` writes a PNG every 30 frames). No headless input. | must not inherit that: they are server.py's children, so they don't, but an SDL3 game started from
| Frame export | screen recording streams raw RGBA frames to an `ffmpeg` unix socket (≤ 30 fps, `compositor/host/recorder.mbt`); screenshots. This is the seed of an encoder feed. | inside Chandra would pick Wayland and render on the CPU. Keep game launches on server.py.
| Shell | every panel piece is a wasm component (launcher, tasks, dock, clock, settings ...), deny-by-default capabilities, reloadable from outside (`chandra-ctl`, control socket). Tiling/floating/maximize/fullscreen window states. Rebindable shortcut table (`state.edn :shortcuts`). | * **Clipboard**: Selkies syncs the X clipboard. Apps inside Chandra use the Wayland clipboard, and
| Desktop-surface modules | **not on main yet**: another thread ("Add desktop-surface modules") started on 2026-11-26. A gamerig launcher would be one of those. | Chandra doesn't bridge the two yet (gap G5). Games are on X, so this only affects the library app.
| Input | libinput (DRM mode) or the host seat (nested). No gamepad/joystick events. |
| Control | control socket: `ping`, `list`, `reload [NAME]`. Easy to extend with kiosk commands. |
| Size | `libwasmtime.so` v51 stripped: 24.0 MB, **8.4 MiB gzip (measured)**; fonts in `assets/` 4.7 MB raw; compositor + module `.wasm` a few MB (est.); runtime libs libdrm, libinput, libudev, libxkbcommon, libseat ≈ 2 MiB gz (est.). Total **≈ 12-18 MiB gz est.** The native build swaps wasmtime for wasmer (similar size). |
## 3. Gap list ## 3. Gap list
Effort is focused engineering time for someone who knows the codebase, before review/hardening. | # | Gap | Effort | Risk | Status |
"Rig" means it can only be verified on a rented NVIDIA host.
| # | Gap | Needed for | Effort | Risk |
| --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| G1 | **Kiosk session profile**: `--kiosk CMD` (or `kiosk` in the session config): no panel and no panel reservation, every compositor shortcut off except an allowlist (switch to home, Alt+Tab) and an admin escape chord; no desktop right-click menu; toplevels forced fullscreen, transient/dialog windows centred floating; respawn the home app when it exits (needs the spawned PID: `@sys.spawn` is detached today, in both hosts) | A and B | 1-2 days | low | | G1 | Kiosk profile: no panel, shortcuts off, desktop menus off, focused window fullscreen, app restarted with backoff, admin escape, `chandra-ctl kiosk`; `--app-id` for the X window's class; `scripts/gamerig-kiosk.sh` | 1 day | low | **done** (d521d0d), rig test pending |
| G2 | **Headless output for an encoder**: export each composed frame (shm ring or a PipeWire stream; the recorder's socket path is a start), let the consumer drive the frame clock, output resize on request | A | 3-5 days | low-medium | | G2 | **Native launcher module**: the calm library as a Chandra desktop module (desktop modules exist since 0f71779): grid, categories, search, running apps, rig status, logs, add app. Needs a capability for modules to call server.py's HTTP API (or the daemon's catalog/launch logic as a host capability) | 1-2 weeks | medium (UI parity; no HTML/CSS engine, so it is a re-implementation sharing calm's tokens) | to do; removes WebKit (≈ 67 MiB) |
| G3 | **Selkies on Wayland**: replace `ximagesrc` with `shmsrc`/`pipewiresrc`/`appsrc` fed by G2; keyboard/pointer injection (either `zwp_virtual_keyboard_v1` + `zwlr_virtual_pointer_v1`, or `key`/`pointer` commands on the control socket) and patch Selkies' input handler the way the ICE wrapper already monkey-patches it; resize via the control socket instead of `xrandr`; clipboard via a data-control protocol or the control socket | A | 1-2 weeks | medium (Selkies 1.6.2 internals, upstream moved to 2.x) | | G3 | **Chandra as the X11 window manager** (replaces Openbox and the fullscreen watcher): `SubstructureRedirect` on the root, map games fullscreen and borderless, leave dialogs (Steam login, file pickers) floating, focus, stacking, `_NET_ACTIVE_WINDOW` / `_NET_CLIENT_LIST` so `wmctrl`/`xdotool` keep working, follow `xrandr`, Ctrl+Alt+L / Super+Space / Alt+Tab across X and Wayland windows. Chandra already speaks the X11 protocol in MoonBit (`compositor/x11`); this is gamerig's own M3 "MoonBit X11 WM" | 1-2 weeks | medium (Steam's odd windows) | to do; removes Openbox (≈ 52 MiB) |
| G4 | **`zwp_linux_dmabuf_v1` (v4, with feedback) and a GPU import path**: protocol and buffer bookkeeping are a few days; getting the pixels out needs either EGL/GBM import + readback on NVIDIA (needs `nvidia-drm.modeset=1` and a render node in the container, the same host conditions that already make Xorg fail on some hosts) or, better, a **zero-copy handoff of a fullscreen client's dmabuf to NVENC** (CUDA external-memory import) that skips composition. Plus explicit sync (`wp_linux_drm_syncobj_v1`) for NVIDIA 555+ correctness | A (hard blocker for games) | 3-6 weeks | **high**, rig | | G4 | Gamepad navigation for modules: read the joystick evdev devices Selkies creates (libinput ignores pads; on `--x11` there is no libinput at all), a WIT gamepad event, focus movement in the launcher | 2-4 days | low | to do |
| G5 | **Xwayland + a small XWM** (ICCCM/EWMH subset: map, fullscreen, transient dialogs, focus, `_NET_ACTIVE_WINDOW` so `wmctrl`/`xdotool`-style focus keeps working) | A, for Steam, xterm, X11-only games, Proton (X11 by default) | 2-4 weeks (GPU accel for X11 games also needs G4) | high | | G5 | Clipboard bridge between X (Selkies) and Chandra's Wayland clients | 1-2 days | low | to do, only for apps inside Chandra |
| G6 | **gamerig launcher as a desktop-surface module**: port the calm library (grid, categories, search, running apps, rig status, logs, add-app) to a Chandra render-list module; it needs a capability to reach `server.py`'s HTTP API (or the daemon's logic moves into a host capability) | A and B | 1-2 weeks after desktop-surface modules land | medium (UI parity; no HTML/CSS layout engine) | | G6 | `onstart.sh` integration: `GAMERIG_SHELL=chandra` runs Chandra instead of `shell_window.py`, same supervisor and health check (`GAMERIG_DESKTOP_EMPTY`), Chandra in the tiny image as its own small layer | 1 day | low | to do (gamerig repo) |
| G7 | **Gamepad navigation for modules**: an evdev reader for joystick devices in the host (libinput ignores them), a WIT gamepad event (buttons, sticks, hotplug), focus/navigation in the launcher. Games keep reading the uinput pads directly | A and B | 2-4 days | low | | — | linux-dmabuf, Xwayland, a Wayland Selkies, encoder frame export | — | — | **not needed** on this path |
| G8 | **Frame pacing**: frame callbacks and `wp_presentation` feedback tied to when a frame is actually taken (encoder or page flip), not to commit | A (stable game frame rate), B | 2-3 days | low |
| G9 | Failure reporting: `GAMERIG_FATAL=` codes and `[gamerig-boot]` phases for Chandra start, dmabuf/GBM availability | A | 1 day | low |
| G10 | Direct scanout / overlay planes for a fullscreen client buffer | B only (and only with G4) | 1-2 weeks | medium |
Not needed from Chandra: audio (PipeWire stays as is), HDR (the pipeline is 8-bit SDR H.264), ## 4. Size
auth/login/updates/Wi-Fi (not on the rig), gamepad delivery to games (uinput, unchanged).
### What a CPU compositor costs here, honestly | Change to `gamerig-tiny` | est. MiB gzip |
| --- | ---: |
| + Chandra package (wasmhost with wasmtime, compositor.wasm, modules, fonts, libinput/libseat/libxkbcommon/libdrm and friends) | **+12 (measured)** |
| − WebKit2GTK kiosk + GTK3 for the window (after G2) | −67 |
| − Openbox chain (imlib2 → libspectre → libgs10 → fonts) and the python-xlib watcher (after G3) | −53 |
| − `taskbar.py`'s GTK use (if Chandra draws the task strip) | small, shares GTK with the above |
| **Net after G2 + G3** | **≈ −105** |
Today's path already goes through the CPU: NVIDIA Xorg composites on the GPU, `ximagesrc` copies the The fonts (4.7 MB raw) are a third of Chandra's package; subsetting them is an easy later win.
whole screen into shared memory (XShm), and `cudaupload` sends it back to the GPU for NVENC. So for Xorg itself stays (≈ 50 MiB est.); replacing it is the Wayland route below and isn't worth it now.
the library UI and other `wl_shm` clients, a CPU-composited Chandra frame handed to the encoder is
**no worse than today**: one 1080p RGBA frame is 8 MB, 60 of them ≈ 500 MB/s of memcpy, within budget
on rig CPUs.
The problem is only the game. A game frame lives in GPU memory; with `wl_shm` it can't get to ## 5. Staged plan
Chandra at GPU speed at all. With G4 the best design *beats* today's path: when the game is
fullscreen and nothing is on top, hand its dmabuf straight to NVENC (no readback, no re-upload, no
composition), and only composite on the CPU when the library, a dialog or the task strip is visible.
That is what gamescope does on the Steam Deck with PipeWire capture, and it is the reference to study
for G4/G5.
## 4. Size, honestly 1. **Stage 1 (built): Chandra as the library window.** `scripts/gamerig-kiosk.sh` on a running rig,
or G6 in onstart. Same library (WebKit inside Chandra), same everything else. Proves the X path
on NVIDIA: capture, XTest input, resize, Ctrl+Alt+L, game on top, back to the library.
2. **Stage 2: native launcher module** (G2 + G4). Drops WebKit from the image. The library becomes
gamepad-navigable inside the stream.
3. **Stage 3: Chandra as the window manager** (G3). Drops Openbox and the watcher; the Alt+Tab and
"back to library" logic moves into one place.
4. **Stage 4: image.** Chandra as its own layer in `Dockerfile.tiny`, WebKit and Openbox removed,
`GAMERIG_SHELL=chandra` the default after an A/B on real rigs.
From gamerig's `docs/tiny-image/DESIGN.md` §3.4 (est., compressed) and the measurements above: ## 6. Rig test status
| Removed from `gamerig-tiny` | est. MiB | Added | est. MiB | The local test (Openbox + Xvfb, 1280x720) passed: Chandra's window is `gamerig-desktop`,
| --- | ---: | --- | ---: | 1280x720+0+0 under Openbox's fullscreen rule; the kiosk app (foot) fills it with no panel; the
| Openbox chain (imlib2 → libspectre → libgs10 → fonts) | 52 | Chandra (wasmtime, components, fonts, libs) | 12-18 | Super tap does nothing; `xdotool type` lands in the app; killing the app brings it back.
| WebKit2GTK kiosk + GTK3 + python3-gi for windows | 67 | `libgbm`/EGL loader for dmabuf import (G4) | 0-50 ¹ |
| python-xlib watcher, `wmctrl`/`xdotool`/`xsel` | ~1 | Xwayland (G5) | ~5-15 ² |
| Xorg core + x11 utils | ~50 ³ | | |
| **Total** | **≈ 170** | | **≈ 20-80** |
¹ `libgbm1` pulls Mesa's gallium + LLVM (≈ 50 MiB est., the "O1" problem in gamerig's design doc) unless Still to run on a Vast rig with gamerig-tiny: `scripts/gamerig-kiosk.sh` replacing the library
the NVIDIA GBM backend can be used without Mesa's loader dependencies; zero for a CUDA-only import. window, WebKit (`shell_window.py`) as a Wayland client on wl_shm, launching `vkcube`/Astra through
² Xwayland itself is small but shares `libgbm`/`libepoxy` with ¹. server.py and returning with Ctrl+Alt+L, Selkies resize. The earlier X11 test on the same host class
³ only if nothing else still needs Xorg; GTK apps (pavucontrol) and Steam need Xwayland instead. already covered MIT-SHM, XTest typing and `xrandr` on NVIDIA.
Net: **≈ 90-150 MiB saved** of ≈ 450 MiB. Pull time drops by the same fraction. Worth having, but ## 7. The Wayland route, for the record
gamerig's own M3 (MoonBit X11 WM + library in the player's browser) saves ≈ 120 MiB (52 + 67) with
none of G2-G5.
## 5. Risks Replacing Xorg with Chandra as a Wayland compositor (the first version of this document) needs
`zwp_linux_dmabuf_v1` with an NVIDIA import path (games can't present to `wl_shm` at GPU speed),
Xwayland + an XWM (Steam, Proton), a Wayland capture/input/resize path for Selkies, and encoder
frame pacing: 2-3 months, with the riskiest part (NVIDIA dmabuf/GBM inside Vast containers)
unverifiable without rentals. It would save Xorg's ≈ 50 MiB more. Not worth it while the X path
works.
| Risk | Impact | Mitigation | ## 8. Reading B: a physical kiosk box
| --- | --- | --- |
| NVIDIA dmabuf/GBM import doesn't work in Vast containers (no `nvidia-drm.modeset`, no render node, missing `/dev/nvidia-modeset`, missing GBM backend) | games can't run under Chandra on those hosts | the spike (stage 0) on one rental; record a `GAMERIG_FATAL` code and bad-host it like `xorg_no_modeset` today; a CUDA-only path avoids GBM |
| Xwayland/XWM is a large, bug-prone area (Steam's windows, popups, focus rules) | Steam unusable | keep Xorg images for Steam until G5 is proven; Astra-only images first |
| Selkies 1.6.2 is pinned and patched; upstream is 2.x | patching for Wayland compounds a fork | treat G3 as part of gamerig's M4 decision (D5); a WebSocket + WebCodecs transport would be written against Chandra's frame export directly |
| Library UI parity: Rabbita/HTML → render-list module | UI drift, double maintenance | port after desktop-surface modules settle; share calm tokens (colours, spacing) |
| Two hosts (MoonBit and Rust) for every host change | double work for G1, G2, G4, G7 | do host work in the MoonBit host first, Rust only if it stays |
| CPU compositing at 1440p/4K 120 Hz | encoder starved, input latency | zero-copy path for fullscreen games (G4); measure CPU per frame with `--profile` |
| Shell code is under heavy parallel change (dock, Exposé, desktop surfaces) | merge churn | kiosk is a profile that switches things *off*; keep it in its own file |
## 6. Staged plan A mini PC booting into Chandra (`--drm`, or `--x11` on NVIDIA) with `--kiosk` running a browser on
gamerig's play page also works today: the browser decodes the stream (software H.264 is fine at
Each stage ends with something running; stop at any stage that disappoints. 1080p60), reads gamepads itself, and the kiosk keeps it fullscreen and restarted.
**Stage 0: go/no-go spike (1-2 weeks, one rental).** Minimal `zwp_linux_dmabuf_v1` in Chandra with
an EGL (or CUDA) import + readback in the headless backend, nothing else. Run `vkcube`, then Astra
(SDL3, `SDL_VIDEODRIVER=wayland`), first on an NVIDIA desktop, then inside a gamerig container on
Vast. Measure: does NVIDIA WSI present at all, fps, per-frame import/readback time, which hosts
fail and why. **If this fails on most Vast hosts, stop rig-side work** and keep Chandra for B.
**Stage 1: minimal kiosk, library-only stream (2-3 weeks, CPU only, no rental).** G1 kiosk profile,
G2 frame export, G3 Selkies shim (capture + input + resize), G6 a first launcher module (grid +
launch + running apps), G9 log contract. Ship as a separate image tag, `gamerig-tiny:chandra-*`,
with Astra launched from the library. Verifiable in the cloud with the headless compositor and a
CPU encoder (`x264enc`).
**Stage 2: games on the GPU (3-5 weeks, rig).** Full G4 with the zero-copy fullscreen path, G8
pacing, G7 gamepad navigation. Acceptance: gamerig's M1 real-rig list (Ready in Ns, NVENC kbps > 0,
Astra at target fps, gamepad, resize, sleep/resume) on the `chandra` tag, A/B against Xorg on the
same host class.
**Stage 3: Steam (2-4 weeks, rig).** G5 Xwayland + XWM. Until then, Steam images keep Xorg.
**Stage 4 (optional).** Drop Xorg from the default image; revisit gamerig's D5 (transport) with
Chandra's frame export as the source.
## 7. Reading B: a physical kiosk box
A small box (mini PC, NUC) booting straight into Chandra on DRM/KMS, showing gamerig's play page in
a fullscreen browser, works with **today's** Chandra plus G1:
* Video: the browser decodes the WebRTC H.264 stream. On `wl_shm` Chromium and Firefox fall back to
software compositing; software H.264 decode of 1080p60 is fine on any recent x86 CPU, 4K60 is not.
Hardware decode (VA-API) needs G4 for zero-copy presentation.
* Gamepads: the browser's Gamepad API reads `/dev/input/event*` itself; Chandra isn't involved.
G7 only matters for a native launcher module on the box.
* Latency: Chandra copies the browser's buffer into its framebuffer and presents on the next page
flip, so expect up to one extra frame versus a direct-scanout compositor (G10 removes it).
* Lockdown: G1 (no panel, shortcuts off, browser respawned, admin chord). Chandra's deny-by-default
module capabilities help here.
## 8. First three concrete steps
1. **Stage 0 spike**: `zwp_linux_dmabuf_v1` + headless import/readback, `vkcube` and Astra on an
NVIDIA machine, then one Vast rental. This is the go/no-go for everything rig-side.
2. **G1 kiosk profile** (`--kiosk CMD`): no panel, shortcut allowlist + admin chord, forced
fullscreen, respawn. Useful for both readings and for testing the launcher; 1-2 days.
3. **G2 + G3 library-only stream**: frame export from headless Chandra into Selkies (`shmsrc` or
`appsrc`) and control-socket input injection, so a browser can see and drive a Chandra desktop
end to end with `x264enc`, before any GPU work lands.