Skip to content

System tray failure causes 'Main loop has exited', preventing headless/server operation on Linux #5170

Closed

Description

@wintrover

Environment

  • Sunshine version: 2026.516.143833
  • OS: Linux Mint 22.3 (Cinnamon X11)
  • GPU: AMD Radeon iGPU (display) + NVIDIA RTX 3060 (PRIME offload)
  • Kernel: 6.17.0-29-generic

Issue 1: System tray crash causes streaming to be unavailable

When running Sunshine without a system tray (headless/server context, or from a systemd user service), the "System tray is not initialized" error causes "Main loop has exited", which prevents the streaming server from fully starting. The web UI becomes partially functional but streaming never works.

Workaround found

Adding system_tray = disabled to ~/.config/sunshine/sunshine.conf fixes this ("No main thread features enabled, skipping event loop"), and streaming then works correctly. However, this option is not well-documented for headless/server setups.

Issue 2: KMS capture requires cap_sys_admin but systemd user services cannot apply ambient capabilities

  • The Sunshine binary has cap_sys_admin,cap_sys_nice=p set via setcap
  • However, when launched via a systemd user service, these capabilities are not carried through to the running process (CapEff=0000000000000000)
  • Setting AmbientCapabilities=CAP_SYS_ADMIN CAP_SYS_NICE in a systemd user service override fails with "Operation not permitted"
  • Workaround: Use capture = x11 instead of KMS (KMS capture not needed)

Issue 3: User needs video group for DRM access

The user must be in the video group to access /dev/dri/card*. Sunshine documentation does not mention this prerequisite.

Suggestions

  1. Document that system_tray = disabled is required for headless/server setups
  2. Document that the user must be in the video group for KMS capture
  3. Consider adding a startup diagnostic that checks these prerequisites
  4. Improve error messages to point the user toward the fix ("Missing video group membership? Missing capabilities?")

Activity

  1. ReenigneArcher commented on May 22, 2026

    @ReenigneArcher
    Member

    Thanks AI

  2. added
    aiPR has signs of heavy ai usage (either indicated by user or assumed)
    on May 22, 2026
  3. darman84 commented on May 22, 2026

    @darman84

    Issue 2 definitely needs to be documented somewhere. I have significantly higher host processing latency when using X11 instead of KMS on a system running Linux mint 22.3 with intel uhd graphics 630. I was able to find this workaround that solved the issue for me:
    To fix Issue 2 and keep KMS capture, you need to run Sunshine as a system service. systemd user services cannot grant the required ambient capabilities.

    Create /etc/systemd/system/sunshine.service and include this under [Service]:

    [Service]
    User=YOUR_USERNAME
    ExecStart=/usr/bin/sunshine
    AmbientCapabilities=CAP_SYS_ADMIN CAP_SYS_NICE
    

    Then swap the services:

    systemctl --user disable --now sunshine.service
    sudo systemctl daemon-reload
    sudo systemctl enable --now sunshine.service
    
  4. ReenigneArcher commented on May 25, 2026

    @ReenigneArcher
    Member

    Document that system_tray = disabled is required for headless/server setups

    This is the only bug here, and probably is no longer required after merging #4907 ... please test beta/pre-release.

    Document that the user must be in the video group for KMS capture

    Never heard of this requirement before. I don't think this is true. Feel free to prove me wrong though.

    Consider adding a startup diagnostic that checks these prerequisites

    Improve error messages to point the user toward the fix ("Missing video group membership? Missing capabilities?")

    Sunshine output/logs already tells you if it doesn't have the right capabilities and what to do in that case.

    PRs accepted for docs or service file improvements.

    Edit: Also, for future reference. Please don't open AI generated issues, and use our issue template.

  5. nomisma-qt commented on May 25, 2026

    @nomisma-qt

    Hi, this issue is closed, but for what it's worth, on Fedora 44 after update to Version 2026.525.22124 (now there is already a newer pre-release as i'm writing this) from an old version 2026.215.224211, everything works now, here's what i had to do:

    After update as USER (not root):
    systemctl --user enable app-dev.lizardbyte.app.Sunshine
    systemctl --user start app-dev.lizardbyte.app.Sunshine

    and then for the CSRF issue, if i connect from a client from ip 10.0.0.10 to Web UI at https://10.0.0.20:47990, i need to add

    csrf_allowed_origins = https://10.0.0.20:47990

    to /home/user/.config/sunshine/sunshine.conf

    and restart service:

    systemctl --user restart app-dev.lizardbyte.app.Sunshine

    now it all works, tray icon works, and no errors in systemd service log:

    $ systemctl --user status app-dev.lizardbyte.app.Sunshine
    ● app-dev.lizardbyte.app.Sunshine.service - Self-hosted game stream host for Moonlight
         Loaded: loaded (/usr/lib/systemd/user/app-dev.lizardbyte.app.Sunshine.service; enabled; preset: disabled)
        Drop-In: /usr/lib/systemd/user/service.d
                 └─10-timeout-abort.conf
                 /run/user/1000/systemd/user.control/app-dev.lizardbyte.app.Sunshine.service.d
                 └─50-CPUWeight.conf, 50-IOWeight.conf
         Active: active (running) since Mon 2026-05-25 22:08:42 EEST; 10min ago
     Invocation: 5264783ef0564708addce51565a31a7c
        Process: 3085 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)
       Main PID: 3087 (sunshine)
          Tasks: 22 (limit: 38341)
         Memory: 84M (peak: 88M)
            CPU: 3.681s
         CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/app-dev.lizardbyte.app.Sunshine.service
                 └─3087 /usr/bin/sunshine
    
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.534]: Info: // Ignore any errors mentioned above, they are not relevant. //
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.534]: Info:
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.534]: Info: Found H.264 encoder: h264_nvenc [nvenc]
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.534]: Info: Found HEVC encoder: hevc_nvenc [nvenc]
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.536]: Info: Starting system tray
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.538]: Info: Adding avahi service fedora-pt
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.545]: Info: Configuration UI available at [https://localhost:47990]
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.689]: Info: System tray created
    May 25 22:09:18 fedora-pt sunshine[3087]: [2026-05-25 22:09:18.689]: Info: Starting main loop
    May 25 22:09:19 fedora-pt sunshine[3087]: [2026-05-25 22:09:19.298]: Info: Avahi service fedora-pt successfully established.
    
  6. agonio commented on May 25, 2026

    @agonio

    Although it might not have been a proper submission via AI summary, I have to add that I currently have exactly the same issues 1 and 2 with the current beta version(s). (Tested today on both v2026.525.145348 and v2026.525.22124)

    I'm coming from bazzite-nvidia 44.20260515 using the homebrew package of sunshine-beta. I updated primarily because of the missing systray icon, but at the moment sunshine-beta is not working anymore for me. I'll paste some logs and a stacktrace (when the systray is enabled; different pid, as the service retries to launch).

    sunshine_systray_disabled.log
    sunshine_systray_enabled.log
    sunshine_systray_enabled_stacktrace.log

    From what I can see the most interesting section are these:

    • with new systray enabled (where the stacktrace follows):
    May 25 22:56:38 bazzite.fritz.box sunshine[11943]: [2026-05-25 22:56:38.830]: Info: Starting system tray
    May 25 22:56:38 bazzite.fritz.box sunshine[11943]: [2026-05-25 22:56:38.830]: Warning: Qt: Could not find the Qt platform plugin "wayland" in ""
    May 25 22:56:38 bazzite.fritz.box sunshine[11943]: [2026-05-25 22:56:38.830]: Warning: Qt: Could not find the Qt platform plugin "xcb" in ""
    May 25 22:56:38 bazzite.fritz.box sunshine[11943]: [2026-05-25 22:56:38.830]: Error: Qt: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    • disabled systray:
    May 25 22:28:01 bazzite.fritz.box sunshine[2808]: [2026-05-25 22:28:01.072]: Warning: setpriority failed for nice -15: Permission denied   // multiple occurences
    May 25 22:28:01 bazzite.fritz.box sunshine[2808]: [2026-05-25 22:28:01.074]: Error: Couldn't import RGB Image: 00003009
    

    ... which will lead to a black screen with error code 1 on moonlight.

    I'm not sure, if my setup is somehow unusual, but I can at least confirm the two issues mentioned above for the latest beta releases. @ReenigneArcher Please reconsider the issue. If you need more info, I'm happy to help.


    EDIT:
    I don't know why that worked, but removing the setcap capabilities via sudo setcap -r $(readlink -f $(which sunshine)) and restarting made my stream work again. (still with disabled systray though) I checked my history from last sunshine update and found this command. For reference, I'll attach another log for the working variant:

    sunshine_setcap-r.log

  7. ReenigneArcher commented on May 25, 2026

    @ReenigneArcher
    Member

    I'd suggest opening a proper issue with reproduction steps.

  8. locked as off topic and limited conversation to collaborators on May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aiPR has signs of heavy ai usage (either indicated by user or assumed)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions