Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

Multiple Input Isolation

Open uebian opened this issue 8 months ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Is your issue described in the documentation?

  • [x] I have read the documentation

Is your issue present in the latest beta/pre-release?

This issue is present in the latest pre-release

Describe the Bug

I started two instances of Sunshine in separate Docker containers on the same host machine. Each container is configured using the following docker-compose definition:

  test1:
    image: <a custom image based on Ubuntu 24.04>
    privileged: true
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: [gpu]
    environment:
      - NVIDIA_DRIVER_CAPABILITIES=all
    volumes:
      - /dev/input/:/dev/input/:ro
    group_add:
      - render
    runtime: nvidia

The host is running LightDM as the display manager and XFCE4 as the desktop environment. systemd is started within each container.

Everything appears to function correctly except for one critical issue: input events are not isolated between the two containers. For example, moving the mouse or pressing a key in one container also generates corresponding input events in the other.

Upon investigation, I found that each Sunshine session creates multiple virtual input devices. Here's the output from xinput list inside one container:

root@test1:/home/ubuntu# xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Wolf mouse (abs) virtual device         	id=9	[slave  pointer  (2)]
⎜   ↳ Mouse passthrough                       	id=10	[slave  pointer  (2)]
⎜   ↳ Wolf mouse (abs) virtual device         	id=14	[slave  pointer  (2)]
⎜   ↳ Mouse passthrough                       	id=15	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Keyboard passthrough                    	id=8	[slave  keyboard (3)]
    ↳ Power Button                            	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Keyboard passthrough                    	id=13	[slave  keyboard (3)]

And here's the list of input devices mounted inside the container:

root@test1:/home/ubuntu# ls /dev/input/
by-path  event0  event1  event10  event11  event12  event13  event14  event15  event16  event17  event2  event3  event4  event5  event6  event7  event8  event9  js0  js1  mice  mouse0  mouse1  mouse2  mouse3

It seems the containers are sharing input devices from the host, which results in overlapping input events across sessions. This behavior breaks the isolation between Sunshine instances and makes parallel usage problematic.

Expected Behavior

The input into the first sunshine instance will not have the impact on the second sunshine instance.

Additional Context

My Xorg configuration as listed below:

Section "ServerLayout"
    Identifier     "DummyLayout"
    Screen         "DummyScreen"
EndSection

Section "Monitor"
    Identifier     "DummyMonitor"
    HorizSync      28.0-80.0
    VertRefresh    48.0-75.0
EndSection

Section "Device"
    Identifier     "DummyDevice"
    Driver         "dummy"
    VideoRam       256000
EndSection

Section "Screen"
    Identifier     "DummyScreen"
    Device         "DummyDevice"
    Monitor        "DummyMonitor"
    DefaultDepth   24
    SubSection "Display"
        Depth      24
        Modes      "1920x1080"
    EndSubSection
EndSection

Host Operating System

Docker

Operating System Version

docker-ce 28.0.4

Architecture

amd64/x86_64

Sunshine commit or version

v2025.122.141614

Package

Linux - deb

GPU Type

NVIDIA

GPU Model

NVIDIA RTX A6000

GPU Driver/Mesa Version

570.124.06

Capture Method

X11 (Linux)

Config

capture = x11

Apps

All

Relevant log output

Mar 29 19:27:40 ubuntu systemd[1]: Started sunshine.service - Sunshine.
Mar 29 19:27:40 ubuntu sunshine[437]: [capture] -- [x11]
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.635]: Info: Sunshine version: v2025.122.141614
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.635]: Info: Package Publisher: LizardByte
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.635]: Info: Publisher Website: https://app.lizardbyte.dev
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.635]: Info: Get support: https://app.lizardbyte.dev/support
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.636]: Warning: Failed to create system tray
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.656]: Info: Detecting displays
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY0 (id: 0)DUMMY0 connected: true
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY1 (id: 1)DUMMY1 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY2 (id: 2)DUMMY2 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY3 (id: 3)DUMMY3 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY4 (id: 4)DUMMY4 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY5 (id: 5)DUMMY5 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY6 (id: 6)DUMMY6 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY7 (id: 7)DUMMY7 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY8 (id: 8)DUMMY8 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY9 (id: 9)DUMMY9 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY10 (id: 10)DUMMY10 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.765]: Info: Detected display: DUMMY11 (id: 11)DUMMY11 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.766]: Info: Detected display: DUMMY12 (id: 12)DUMMY12 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.766]: Info: Detected display: DUMMY13 (id: 13)DUMMY13 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.766]: Info: Detected display: DUMMY14 (id: 14)DUMMY14 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.766]: Info: Detected display: DUMMY15 (id: 15)DUMMY15 connected: false
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.855]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.855]: Info: Trying encoder [nvenc]
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.855]: Info: Screencasting with X11
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.880]: Info: Creating encoder [h264_nvenc]
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.880]: Info: Color coding: SDR (Rec. 601)
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.880]: Info: Color depth: 8-bit
Mar 29 19:27:40 ubuntu sunshine[437]: [2025-03-29 19:27:40.880]: Info: Color range: JPEG
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.344]: Info: Creating encoder [hevc_nvenc]
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.344]: Info: Color coding: SDR (Rec. 601)
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.344]: Info: Color depth: 8-bit
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.344]: Info: Color range: JPEG
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.608]: Info: Creating encoder [av1_nvenc]
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.609]: Info: Color coding: SDR (Rec. 601)
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.609]: Info: Color depth: 8-bit
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.609]: Info: Color range: JPEG
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.615]: Warning: [av1_nvenc @ 0x55e465482d00] Codec not supported
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.615]: Error: [av1_nvenc @ 0x55e465482d00] Provided device doesn't support required NVENC features
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.865]: Error: Could not open codec [av1_nvenc]: Function not implemented
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.865]: Info: Screencasting with X11
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.866]: Info: Creating encoder [hevc_nvenc]
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.866]: Info: Color coding: SDR (Rec. 709)
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.866]: Info: Color depth: 10-bit
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.866]: Info: Color range: JPEG
Mar 29 19:27:41 ubuntu sunshine[437]: [2025-03-29 19:27:41.885]: Error: cuda::cuda_t doesn't support any format other than AV_PIX_FMT_NV12
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.127]: Info:
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.127]: Info: // Ignore any errors mentioned above, they are not relevant. //
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.127]: Info:
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.127]: Info: Found H.264 encoder: h264_nvenc [nvenc]
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.127]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.128]: Info: Adding avahi service ubuntu
Mar 29 19:27:42 ubuntu sunshine[437]: [2025-03-29 19:27:42.130]: Info: Configuration UI available at [https://localhost:47990]
Mar 29 19:27:43 ubuntu sunshine[437]: [2025-03-29 19:27:43.021]: Info: Avahi service ubuntu successfully established.

uebian avatar Mar 29 '25 20:03 uebian

I think this is to be expected given how inputtino works. I have found a project that achieved virtual device input isolation

https://games-on-whales.github.io/wolf/stable/dev/fake-udev.html

It involves creating udev rules to ignore virtual devices on the host and then faking the udev events inside the container.

XT-Martinez avatar Apr 02 '25 16:04 XT-Martinez

It seems this issue hasn't had any activity in the past 90 days. If it's still something you'd like addressed, please let us know by leaving a comment. Otherwise, to help keep our backlog tidy, we'll be closing this issue in 10 days. Thanks!

LizardByte-bot avatar Jul 02 '25 10:07 LizardByte-bot

This issue was closed because it has been stalled for 10 days with no activity.

LizardByte-bot avatar Jul 13 '25 10:07 LizardByte-bot

Hey 👋,

I’ve been working on a small project that directly addresses the exact problem you’re describing — input isolation when running multiple Sunshine instances in containers.

Normally, when /dev/uinput is bind-mounted into containers, all instances share the same kernel-level uinput interface. That means devices created in one container are visible system-wide (and thus to other containers), so input events leak across instances — exactly like what you’re seeing.

My project vuinputd is a CUSE-based proxy for /dev/uinput. It lets unmodified applications like Sunshine create virtual input devices inside containers, while the actual device creation happens safely on the host. Each container gets its own mediated /dev/uinput, and vuinputd ensures:

🧩 Devices from one container don’t leak into others

🔒 The host ignores those devices (via udev isolation)

🎮 SDL2 / Wayland apps inside the container still see proper udev events

It currently works with systemd-nspawn, but the design also applies to Docker, LXC, and other runtimes — no kernel patches or special drivers needed.

If you’re experimenting with multi-instance Sunshine or containerized GPU game streaming, this approach could solve your input collision issue. The project is still in an early prototype stage, but it’s functional — you can find the details here: 👉 https://github.com/joleuger/vuinputd

joleuger avatar Oct 26 '25 22:10 joleuger

@joleuger Sounds awesome. Once you feel it's a little more stable feel free to add it to https://github.com/LizardByte/awesome-sunshine

ReenigneArcher avatar Oct 27 '25 00:10 ReenigneArcher