Bug 448475

Summary: With systemd boot disabled, Plasmashell doesn't automatically restart when kwin_wayland crashes or is manually restarted
Product: [Plasma] plasmashell Reporter: Nate Graham <nate>
Component: Startup processAssignee: Plasma Bugs List <plasma-bugs>
Status: CONFIRMED ---    
Severity: minor CC: agurenko, ahiemstra, bugseforuns, kde, kde, lee295012, qydwhotmail, valerio.p
Priority: NOR Keywords: regression, wayland
Version: master   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=474995
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: journalctl log
`systemctl --user show plasma-plasmashell.service` output

Description Nate Graham 2022-01-14 16:19:21 UTC
For the past several weeks (sorry for not reporting it earlier), plasma fails to auto-restart when kwin_wayland crashes. KRunner does, so I have been using krunner to launch Plasma manually, which works. But it seems like plasmashell should come up automatically.
Comment 1 Fushan Wen 2022-01-15 01:20:13 UTC
It seems I encountered the same bug yesterday when I was testing Firefox behavior on Wayland. I didn't pay attention to other details, and I only remember I plugged out and in a Type-C converter (which contains a HDMI port, an RJ45 port and some USB ports)
Comment 2 Nate Graham 2022-01-16 15:20:20 UTC
Also happens when I manually restart kwin_wayland.
Comment 3 Fushan Wen 2022-01-16 15:41:23 UTC
plasmashell can be automatically restarted after `kwin_wayland --replace` on 5.23.4.
Comment 4 Fushan Wen 2022-01-16 15:57:04 UTC
I ran `kwin_wayland --replace` and plasmashell was successfully restarted on git master (5.24.80).
Comment 5 Nate Graham 2022-01-16 16:12:05 UTC
I can still reproduce the issue with current git master.
Comment 6 Arjen Hiemstra 2022-01-20 12:08:07 UTC
Is this with or without systemd startup?
Comment 7 Nate Graham 2022-01-20 15:01:19 UTC
With.
Comment 8 David Edmundson 2022-01-20 16:45:32 UTC
Works here, we need some logs from "journalctl --user -b" after reproducing
Comment 9 Nate Graham 2022-01-21 16:15:33 UTC
Created attachment 145719 [details]
journalctl log
Comment 10 Nate Graham 2022-01-21 16:15:43 UTC
Attached the requested log.
Comment 11 David Edmundson 2022-01-24 21:20:12 UTC
>app-plasmashell-

That makes no sense. It means it's being autostarted from either the user manually or there exists a /etc/xdg/autostart/org.kde.plasmashell.desktop that's super outdated and doesn't have the line X-systemd-skip=true

All points to a local setup issue. 

systemctl --user show plasma-plasmashell.service.
Comment 12 Nate Graham 2022-01-25 15:23:05 UTC
Created attachment 145916 [details]
`systemctl --user show plasma-plasmashell.service` output

There is /etc/xdg/autostart/org.kde.plasmashell.desktop, but it has X-systemd-skip=true in it.

I am attaching the output of `systemctl --user show plasma-plasmashell.service`. All the paths in it seem to point to my built-from-source stuff.
Comment 13 Fushan Wen 2022-01-26 11:19:06 UTC
I encountered the same problem. Manually restarting kwin_wayland can restart plasmashell though ,but after kwin_wayland  crashes and automatically restarts, plasmashell won't be there.
Comment 14 Fushan Wen 2022-01-26 11:20:34 UTC
Update: Running `kwin_wayland --replace` can't restart plasmashell now
Comment 15 Fushan Wen 2022-01-26 11:42:28 UTC
Update: when the bug happens, I can't logout/restart/shutdown from Kickoff.
Comment 16 Nate Graham 2022-01-26 15:44:09 UTC
(In reply to Fushan Wen from comment #15)
> Update: when the bug happens, I can't logout/restart/shutdown from Kickoff.
Sounds like Bug 448517.
Comment 17 David Edmundson 2022-01-27 12:05:26 UTC
Fushan do you also have a self compiled KDE alongside distro packages?
Comment 18 David Edmundson 2022-01-27 12:11:02 UTC
Edit:
Jan 21 09:11:50 Liberator systemd[1255]: app-plasmashell-b2281e652ea9446591db0bff66da1800.scope: Consumed 2min 30.774s CPU time.

This being a scope means it wasn't handled by the xdg-autostart.

There's only one explanation. The user typed "plasmashell --replace" into krunner at which point the session isn't managing it.
Comment 19 Patrick Silva 2022-01-27 12:26:02 UTC
can reproduce this bug on neon unstable.

1. reproduce kwin_wayland crash reported as bug 446318

result: I see a black screen with mouse pointer and Plasma is not automatically restarted.
Plasma manually restarted with 'plasmashell --replace' is unusable.
Right-click on desktop, logout/reboot/shutdown via kickoff do not work.
Comment 20 Fushan Wen 2022-01-27 14:02:19 UTC
(In reply to David Edmundson from comment #17)
> Fushan do you also have a self compiled KDE alongside distro packages?

I usually install and update packages from the unstable-kde repo from openSUSE, and only manually compile packages when I need it.
Comment 21 Fushan Wen 2022-01-27 14:12:02 UTC
I guess systemd refuses to restart plasmashell after a limit. I can still see plasmashell is restarted for the first time it crashes.
Comment 22 Nate Graham 2022-01-27 15:53:43 UTC
(In reply to David Edmundson from comment #18)
> Edit:
> Jan 21 09:11:50 Liberator systemd[1255]:
> app-plasmashell-b2281e652ea9446591db0bff66da1800.scope: Consumed 2min
> 30.774s CPU time.
> 
> This being a scope means it wasn't handled by the xdg-autostart.
> 
> There's only one explanation. The user typed "plasmashell --replace" into
> krunner at which point the session isn't managing it.
I restart plasmashell with `kstart5 -- plasmashell --replace` so that it gets managed in a cgroup.

When I restart plasmashell like this, and then restart kwin with `kstart5 -- kwin_wayland --replace`, plasmashell doesn't get automatically started like I would expect.

This can't possibly be an unsupported thing to do. If it is, there is a design flaw in the way our auto-restarting infrastructure works that we need to fix.
Comment 23 Patrick Silva 2022-02-10 16:35:59 UTC
(In reply to Patrick Silva from comment #19)
> can reproduce this bug on neon unstable.
> 
> 1. reproduce kwin_wayland crash reported as bug 446318
> 
> result: I see a black screen with mouse pointer and Plasma is not
> automatically restarted.
> Plasma manually restarted with 'plasmashell --replace' is unusable.
> Right-click on desktop, logout/reboot/shutdown via kickoff do not work.

problem with logout, reboot and shutdown reported as bug 449948
Comment 24 Nate Graham 2022-05-11 14:03:56 UTC
*** Bug 453639 has been marked as a duplicate of this bug. ***
Comment 25 David Edmundson 2022-05-13 07:09:13 UTC
>can reproduce this bug on neon unstable.

Patrick can you confirm if this happens after a clean boot and a kwin restart or if you had also manually explicitly replaced plasmashell before the kwin restart?
Comment 26 Patrick Silva 2022-05-13 10:39:29 UTC
Tested on neon unstable right now:

1. boot
2. login to Wayland
3. ran 'kwin_wayland --replace' with krunner

Result: black screen with mouse pointer
Comment 27 Nate Graham 2022-05-13 13:43:53 UTC
I can reproduce that too.
Comment 28 Gurenko Alex 2022-05-13 13:46:31 UTC
Interesting, I've just tried it on Lenovo P1 gen2 (Intel GPU) on Fedora 36 and it replaced it perfectly. Also I've recently noticed that on my desktop with AMD GPU it also recovered and restarted after a GPU driver reset.
Comment 29 David Redondo 2022-08-12 09:33:43 UTC
> Patrick can you confirm if this happens after a clean boot and a kwin restart or if you had also manually explicitly replaced plasmashell before the kwin restart?

I can on KDE Neon, note that kde neon doesnt use systemd boot because of to old systemd without xdg autostart generator support
Comment 30 Nate Graham 2022-08-12 15:59:11 UTC
After some investigation today, we found that ultimately this was caused by me using systemd boot but not restarting plasmashell using the systemd boot tools. I was doing:

kquitapp5 plasmashell && kstart5 plasmashell

instead of:

systemctl restart --user plasma-plasmashell.service

Ultimately I was doing that to work around https://bugs.kde.org/show_bug.cgi?id=439159, but the systemctl command doesn't seem to cause it either, which is nice. Switching to `systemctl restart --user plasma-plasmashell.service` fixes the issue entirely with systemd boot.

This is still valid for the non-systemd case though; re-titling to be about that.