What gamerig's rig-side shell does today (headless NVIDIA Xorg, Openbox, WebKit library window, Selkies X11 capture/input), what Chandra has, the gap list with effort and risk, size estimate, staged plan with a dmabuf go/no-go spike first, and the physical thin-client reading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
19 KiB
Chandra as the gamerig kiosk: feasibility
Question (V, 2026-11-26): gamerig, the game streaming platform (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, what Chandra has, what is missing, and in what order to close the gaps. Numbers marked measured were measured for this document; est. are estimates with the method given.
TL;DR
- 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
(
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 the library UI + a GTK taskbar. Chandra would replace that stack, and ideally Xorg too, on the rig. - Chandra can't do that today, and the reason is not the shell. The shell side (fullscreen
single-app policy, no panel, locked shortcuts, a launcher as a module) is small work. The blockers
are the display-server plumbing a streaming rig needs:
- Games can't present to Chandra with the GPU. NVIDIA's Vulkan/EGL Wayland WSI needs
zwp_linux_dmabuf_v1; Chandra only haswl_shm. Without it a game either fails (the tiny image has no Mesa software Vulkan) or runs on lavapipe/llvmpipe, which is unplayable. This project already saw it with Zed/Delta falling back to llvmpipe. - Steam (and Proton games by default) are X11 clients. Chandra has no Xwayland/XWM.
- Selkies 1.6.2 is X11-only: capture is
ximagesrc, keyboard/mouse injection is XTest, resize isxrandr, clipboard isxsel. A Wayland compositor needs a new capture source, an input-injection path, resize and clipboard hooks. - No frame export or frame pacing for an encoder. Headless Chandra renders into a CPU framebuffer at a fixed ~60 Hz loop and only writes PNGs; frame callbacks fire on commit.
- Games can't present to Chandra with the GPU. NVIDIA's Vulkan/EGL Wayland WSI needs
- The size win is real but modest. Chandra itself is ≈ 12-18 MiB compressed est.
(
libwasmtime.so8.4 MiB gz measured, fonts 4.7 MB raw, components and small libs). It would remove Openbox (≈ 52 MiB est.), the WebKit2GTK kiosk (≈ 67 MiB est.) and maybe Xorg core, but GPU buffer import bringslibgbm/EGL back, and Xwayland brings part of the X stack back. Expect ≈ 100-120 MiB saved out of the ≈ 450 MiBgamerig-tinyimage (est.). gamerig's own plan (docs/tiny-image/DESIGN.mdM3: a MoonBit X11 WM plus a browser-side library) gets most of that win with much less risk. - Recommendation: not yet as a replacement for the rig's display stack. Go with caveats on a
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
--kioskprofile.
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
Read from docker/onstart.sh (3,758 lines), docker/desktop/*.py, desktop/ui/, docker/Dockerfile.tiny
and docs/tiny-image/DESIGN.md in the gamerig repo (commit 375ac7e).
| Piece | Today | Kiosk duty a replacement must cover |
|---|---|---|
| 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 |
| 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 |
| Fullscreen watcher | Python + python-xlib loop in onstart (start_fullscreen_watcher) keeping game windows snapped fullscreen, skipping dock windows |
the compositor does this itself |
| 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 |
| 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 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 |
| Taskbar | taskbar.py: GTK dock bar, Library button + a button per window (wmctrl -l -x) |
a minimal task strip, or Alt+Tab only |
| 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 |
| 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 |
| Resize / clipboard | xrandr resize to the browser's size (with a resize probe and fallback); xsel clipboard |
output resize and clipboard hooks |
| 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,
Big Picture), Lutris/Heroic, vkcube, xterm, pavucontrol, a WebKit browser window, the Roblox
(MoonBit, GTK4) launcher.
2. What Chandra has
From main at 42aa770.
| Area | Status |
|---|---|
| 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. |
| 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). |
| 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. |
| 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. |
| 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). |
| 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. |
| 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
Effort is focused engineering time for someone who knows the codebase, before review/hardening. "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 |
| 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 |
| 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) |
| 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 |
| 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 |
| 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) |
| 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 |
| 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), auth/login/updates/Wi-Fi (not on the rig), gamepad delivery to games (uinput, unchanged).
What a CPU compositor costs here, honestly
Today's path already goes through the CPU: NVIDIA Xorg composites on the GPU, ximagesrc copies the
whole screen into shared memory (XShm), and cudaupload sends it back to the GPU for NVENC. So for
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
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
From gamerig's docs/tiny-image/DESIGN.md §3.4 (est., compressed) and the measurements above:
Removed from gamerig-tiny |
est. MiB | Added | est. MiB |
|---|---|---|---|
| Openbox chain (imlib2 → libspectre → libgs10 → fonts) | 52 | Chandra (wasmtime, components, fonts, libs) | 12-18 |
| 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
the NVIDIA GBM backend can be used without Mesa's loader dependencies; zero for a CUDA-only import.
² Xwayland itself is small but shares libgbm/libepoxy with ¹.
³ only if nothing else still needs Xorg; GTK apps (pavucontrol) and Steam need Xwayland instead.
Net: ≈ 90-150 MiB saved of ≈ 450 MiB. Pull time drops by the same fraction. Worth having, but 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
| Risk | Impact | Mitigation |
|---|---|---|
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
Each stage ends with something running; stop at any stage that disappoints.
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_shmChromium 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
- Stage 0 spike:
zwp_linux_dmabuf_v1+ headless import/readback,vkcubeand Astra on an NVIDIA machine, then one Vast rental. This is the go/no-go for everything rig-side. - 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. - G2 + G3 library-only stream: frame export from headless Chandra into Selkies (
shmsrcorappsrc) and control-socket input injection, so a browser can see and drive a Chandra desktop end to end withx264enc, before any GPU work lands.