Skip to content

Use xdg-desktop-autostart.target for systemd service.#901

Merged
ReenigneArcher merged 1 commit intoLizardByte:nightlyfrom
HomerSp:systemd-use-xdg-autostart
Mar 20, 2023
Merged

Use xdg-desktop-autostart.target for systemd service.#901
ReenigneArcher merged 1 commit intoLizardByte:nightlyfrom
HomerSp:systemd-use-xdg-autostart

Conversation

@HomerSp
Copy link
Contributor

@HomerSp HomerSp commented Feb 8, 2023

Description

This fixes an issue where sunshine could randomly start before the window manager on wayland, causing the wm to error with Device or resource busy on the kms/dri device. This would prevent the desktop from running at all, and all you would see is a black screen. This seems to happen on both gnome and plasma when using wayland (I've only tested it on plasma).
The fix is simply to have the sunshine systemd service start after xdg-desktop-autostart.target, which happens when other autostart apps run, and that's always after the window manager is ready.

Screenshot

Issues Fixed or Closed

Fixes #334

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@KuleRucket
Copy link
Contributor

This seems to cause problems for me in KDE:
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found ordering cycle on app-geoclue\x2ddemo\x2dagent@autostart.service/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on graphical-session.target/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on sunshine.service/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on xdg-desktop-autostart.target/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Job app-geoclue\x2ddemo\x2dagent@autostart.service/start deleted to break ordering cycle starting with xdg-desktop-autostart.target/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found ordering cycle on app-steam@autostart.service/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on graphical-session.target/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on sunshine.service/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Found dependency on xdg-desktop-autostart.target/start
Feb 11 10:30:07 monster systemd[1048]: xdg-desktop-autostart.target: Job app-steam@autostart.service/start deleted to break ordering cycle starting with xdg-desktop-autostart.target/start
Feb 11 10:30:07 monster systemd[1048]: app-org.kde.discover.notifier@autostart.service: Found ordering cycle on graphical-session.target/start
Feb 11 10:30:07 monster systemd[1048]: app-org.kde.discover.notifier@autostart.service: Found dependency on sunshine.service/start
Feb 11 10:30:07 monster systemd[1048]: app-org.kde.discover.notifier@autostart.service: Found dependency on xdg-desktop-autostart.target/start
Feb 11 10:30:07 monster systemd[1048]: app-org.kde.discover.notifier@autostart.service: Found dependency on app-org.kde.discover.notifier@autostart.service/start
Feb 11 10:30:07 monster systemd[1048]: app-org.kde.discover.notifier@autostart.service: Job sunshine.service/start deleted to break ordering cycle starting with app-org.kde.discover.notifier@autostart.service/start

@HomerSp
Copy link
Contributor Author

HomerSp commented Feb 11, 2023

@KuleRucket Hmm, I'm also using plasma and don't seem to have this issue. I've been trying to figure out a way to ensure the systemd service of sunshine to run after kwin has started (otherwise kwin will fail to start), and this was the only way I could find. I'll keep looking though, thanks for reporting the issue!

@KuleRucket
Copy link
Contributor

I use login/logout scripts as mentioned in #78

@RevengeRip
Copy link

I tried it for myself and it works great on Kubuntu 22.10, can't wait to see it upstream! I used timer unit before.

@KuleRucket
Copy link
Contributor

Tried this again and I don't get a cyclic service dependency and longer. I think that there might have been local changes to the service in place when I tested it. Having said that, it doesn't work for me but it's no worse than before. If it fixes things for others then it should be merged.

@KuleRucket
Copy link
Contributor

KuleRucket commented Mar 20, 2023

Actually, it does work. I realised that I needed to disable/enable the service again to pick up the [Install] changes.

@ReenigneArcher ReenigneArcher force-pushed the systemd-use-xdg-autostart branch from 7b92f2c to d0a7d3e Compare March 20, 2023 13:47
@ReenigneArcher ReenigneArcher merged commit a192c50 into LizardByte:nightly Mar 20, 2023
@gschintgen
Copy link
Contributor

Hi, I just wanted to point out that the newly merged systemd unit doesn't seem to work on my setup. (I tested it with a recent test build, the one from #93.) As far as I can tell the boot/login sequence never calls/reaches the xdg target.
That's with Ubuntu 22.04.2 (gnome, wayland). I'm not sure why though.

I'll continue using my own .service but wanted to give a quick heads-up about this PR. (My working solution is unfortunately non-portable since it targets After=gnome-session.target.)

@PVermeer
Copy link
Contributor

Hi, I just wanted to point out that the newly merged systemd unit doesn't seem to work on my setup. (I tested it with a recent test build, the one from #93.) As far as I can tell the boot/login sequence never calls/reaches the xdg target. That's with Ubuntu 22.04.2 (gnome, wayland). I'm not sure why though.

I'll continue using my own .service but wanted to give a quick heads-up about this PR. (My working solution is unfortunately non-portable since it targets After=gnome-session.target.)

Same here on Manjaro Gnome X11.

@KuleRucket
Copy link
Contributor

KuleRucket commented Mar 28, 2023

I think the real solution to all of this is to re-work sunshine initialisation so that it can start up without any UI/desktop environment being present rather than trying to find a systemd target that works on every DE. It can initialise the display elements later once it becomes available. I have an idea that the web server configuration should be present regardless of what issues there are in the screen capture/encoding set up so that you can adjust settings even if the rest is broken.

@ReenigneArcher
Copy link
Member

I have an idea that the web server configuration should be present regardless of what issues there are in the screen capture/encoding set up so that you can adjust settings even if the rest is broken.

There were some attempts to improve on this, but I don't think we're catching all crashes right now.

#710
#648

@artemklevtsov
Copy link

artemklevtsov commented Apr 2, 2023

I faced with the same problem on KDE X11 (Sunshine v0.19.1, Arch Linux):

❯ systemctl --user status sunshine.service --no-pager -l
○ sunshine.service - Sunshine is a self-hosted game stream host for Moonlight.
     Loaded: loaded (/usr/lib/systemd/user/sunshine.service; enabled; preset: enabled)
     Active: inactive (dead)

апр 02 11:11:22 unikum-desktop systemd[884]: xdg-desktop-autostart.target: Found ordering cycle on app-Yandex.Disk@autostart.service/start
апр 02 11:11:22 unikum-desktop systemd[884]: xdg-desktop-autostart.target: Found dependency on graphical-session.target/start
апр 02 11:11:22 unikum-desktop systemd[884]: xdg-desktop-autostart.target: Found dependency on sunshine.service/start
апр 02 11:11:22 unikum-desktop systemd[884]: xdg-desktop-autostart.target: Found dependency on xdg-desktop-autostart.target/start
апр 02 11:11:22 unikum-desktop systemd[884]: xdg-desktop-autostart.target: Job app-Yandex.Disk@autostart.service/start deleted to break ordering cycle starting with xdg-desktop-autostart.target/start
апр 02 11:11:22 unikum-desktop systemd[884]: app-snapshot\x2ddetect@autostart.service: Found ordering cycle on graphical-session.target/start
апр 02 11:11:22 unikum-desktop systemd[884]: app-snapshot\x2ddetect@autostart.service: Found dependency on sunshine.service/start
апр 02 11:11:22 unikum-desktop systemd[884]: app-snapshot\x2ddetect@autostart.service: Found dependency on xdg-desktop-autostart.target/start
апр 02 11:11:22 unikum-desktop systemd[884]: app-snapshot\x2ddetect@autostart.service: Found dependency on app-snapshot\x2ddetect@autostart.service/start
апр 02 11:11:22 unikum-desktop systemd[884]: app-snapshot\x2ddetect@autostart.service: Job sunshine.service/start deleted to break ordering cycle starting with app-snapshot\x2ddetect@autostart.service/start

@Jonathan34
Copy link

I confirm this does not start sunshine.service on startup after xdg on ubuntu Jammy.
I have set an autostart script to run systemctl --user start sunshine and then the service starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants