[Bug]: cua-spacesd streams a black desktop on niri (Wayland backend is gated on HYPRLAND_INSTANCE_SIGNATURE)
Primary area
Other (Cua Spaces / cua-spacesd desktop streaming)
Summary
In a local QEMU Space whose guest desktop is niri (Wayland), the Space viewer shows an all-black desktop. cua-spacesd's Wayland capture backend is only selected when HYPRLAND_INSTANCE_SIGNATURE is set, so on niri it falls back to the X11 backend, which captures the rootless Xwayland display :0 (provided by xwayland-satellite) and gets black frames. The pixel path that the Wayland backend already uses (wlr-screencopy) is implemented by niri, so the missing piece looks like backend selection plus output/window enumeration through niri IPC, not capture itself.
Reproduction
- Create a local QEMU Space from a disk image whose guest auto-logs into a niri session (here: Pond Linux, Arch-based), with cua-spacesd 0.8.0 running as the desktop user and
--gpu virgl. - Wait until the niri session is up (cua-driver inside the guest can take screenshots of it, so the session and compositor are working).
- Open the Space in the Cua Spaces viewer (or open a desktop media session with
stream_endpoint).
Expected behavior
The viewer streams the niri desktop, or cua-spacesd reports that this Wayland compositor is unsupported instead of streaming black frames.
Actual behavior
The Space is reachable and advertises desktop_stream; shell, file and cua-driver tools work. The desktop stream opens and encodes frames, but they are black. The guest desktop itself is fine: viewing the same VM through QEMU's own display (VNC / -display gtk,gl=on) shows the niri desktop rendering normally.
Environment
- Cua components: cua-spacesd 0.8.0 (guest), cua-driver 0.37.0 (guest), cua CLI 0.9.0, Cua Spaces app 0.16.0
- Guest: Pond Linux (Arch-based, rolling), niri 26.04 (8ed0da4), xwayland-satellite 0.8.3 + Xwayland 24.1.14 (rootless
:0), sddm autologin intoniri.desktop; single outputVirtual-1 - Host: CachyOS x86_64, QEMU 11.1.2 (KVM),
virtio-gpu-gl-pci(virgl), NVIDIA RTX 3060 - The host also runs niri 26.04, and
grim(wlr-screencopy) captures its output fine, which is the protocol cua-spacesd's Wayland backend uses.
Evidence
cua-spacesd's environment (/proc/<pid>/environ, filtered): niri is detectable, but the Hyprland variable the backend checks is absent.
CUA_DRIVER_RS_ENABLE_WAYLAND=1
XDG_SESSION_TYPE=wayland
XDG_CURRENT_DESKTOP=niri
WAYLAND_DISPLAY=wayland-1
NIRI_SOCKET=/run/user/1000/niri.wayland-1.<pid>.sock
DISPLAY=:0
(no HYPRLAND_INSTANCE_SIGNATURE)
:0 is a rootless Xwayland with nothing on it, which is what the X11 fallback grabs:
$ DISPLAY=:0 xprop -root _NET_CLIENT_LIST
_NET_CLIENT_LIST: not found.
$ DISPLAY=:0 ffmpeg -f x11grab -i :0 -frames:v 1 x0.png # magick: 1242x1317, mean=3.6e-05 (black)
$ niri msg -j outputs # Virtual-1 logical {x: 0, y: 0, width: 1242, height: 1317, scale: 1.0}
The stream itself is healthy but empty: a desktop media session (stream_endpoint, h264, 5 fps) delivered ~21 KB in 8 s, consistent with a static black frame. The spacesd journal shows only the normal startup and the OpenH264 encoder starting, no capture errors:
INFO cua_spacesd: cua-spacesd 0.8.0 serving addr=0.0.0.0:3211 ...
[OpenH264] ... Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.
Backend selection, identical in cua-spacesd-v0.8.0 and current main (6660c7d):
libs/cua-spacesd/crates/cua-spacesd-desktop/src/linux_wayland.rsL80-82:pub(super) fn active() -> bool { std::env::var_os("HYPRLAND_INSTANCE_SIGNATURE").is_some() }lib.rsuseslinux_wayland::active()to choose between this backend andlinux_x11fordisplays()(L834), display capture (L1681, L1703) and window enumeration (L2479). With it false, niri sessions go tolinux_x11::connect().- The module doc says the Wayland backend takes pixels from
wlr-screencopy(orgrimas a fallback); only enumeration, geometry and resize go through Hyprland IPC /hyprctl.
Workaround and additional context
- No workaround inside Cua; I view the VM through QEMU's own display instead.
- A possible shape for the fix:
- Treat
NIRI_SOCKET(niri exports it into the session) as a Wayland session too, and keep a per-compositor window manager next toHyprlandWindowManager. - Full-desktop streaming needs only outputs: niri IPC
Outputs(niri msg -j outputs) gives each output's logical position and size, and the existingwlr-screencopypath does the rest. - Per-window streams and focus/resize could follow what #5523 does for cua-driver (niri IPC
Windows,focus-window --id; tiled windows have no position in IPC yet, niri-wm/niri#4369).
- Treat
- Related: #3735 / #5523 (niri adapter for cua-driver input; does not touch cua-spacesd), #5236 (same class of bug on GNOME 50 Wayland: black stream from the X11 path).
Submission checks
- [x] I searched for duplicate issues and active pull requests.
Thanks, Ayuilos. The backend-selection analysis (Wayland path gated on the Hyprland env var, X11 fallback capturing black frames on niri) is helpful. We're looking into it.