cua icon indicating copy to clipboard operation
cua copied to clipboard

[Bug]: cua-spacesd hangs in drm_modeset_lock on Linux host with desktop sharing on (Hyprland, NVIDIA)

Open dantraynor opened this issue 1 month ago • 1 comments

With share_desktop=on, cua-spacesd answers one GetCapabilities over the relay, then hangs. One tokio worker is blocked in drm_modeset_lock. After that the relay socket is never read again, every request times out, and SIGTERM doesn't stop the service. With --desktop off it works.

Possibly related: #5236 (same GPU combination, Wayland capture path) and #5376 (a capture lock stalling the whole daemon, on macOS).

Environment

  • cua 0.4.4, cua-spacesd 0.5.3, Cua Spaces 0.9.4
  • Omarchy (Arch), kernel 7.2.3-arch1-3
  • Hyprland 0.56.2
  • RTX 3090 on nvidia-open 610.57.04 (nvidia_drm modeset=Y fbdev=Y), plus an AMD iGPU
  • Set up with install.sh --pair; systemd service running as root, relay mode, no WAYLAND_DISPLAY/XDG_RUNTIME_DIR in its environment

Repro

  1. Pair a Linux host with the defaults (desktop sharing on).
  2. From another device, run any command on it (space_bash hostname).

The command fails with nothing answered at https://relay.cua.ai/m/<id> … no answer within 15s and the machine shows offline. access.log records only the GetCapabilities. driver.log ends at joined relay with no errors.

The relay socket's Recv-Q grows and never drains (0 → 4999 → 16628 over a few minutes).

Threads (/proc/<pid>/task/*/wchan):

cua-spacesd       futex_do_wait
tokio-rt-worker   futex_do_wait   x7
tokio-rt-worker   drm_modeset_lock
cuda00004000011   poll_schedule_timeout

Stopping always ends in SIGKILL:

cua-spacesd-host.service: State 'stop-sigterm' timed out. Killing.

A restart buys one request at most.

Workaround

cua host config --desktop off
systemctl kill -s KILL cua-spacesd-host; systemctl restart cua-spacesd-host

After that it stays connected and serves requests. Providing Spaces through Docker still works.

Guess The desktop path seems to touch KMS directly from root while Hyprland holds the modeset lock. That blocking call runs on an async worker, so it takes the relay reader and shutdown down with it. Moving capture to spawn_blocking with a timeout would at least keep the daemon alive. Using the session's xdg-desktop-portal/PipeWire on Wayland would avoid the lock altogether.

dantraynor avatar Oct 18 '26 03:10 dantraynor

Thanks, the stack and the --desktop off workaround are very useful. Linking #5376, which looks like the same kind of problem on macOS (a capture lock stalling the whole daemon), and #5236 (same GPU combination). @injaneity is looking into it; we'll update here.

f-trycua avatar Oct 18 '26 06:10 f-trycua