Bug 432364

Summary: [systemd] plasma-ksmserver.service blocks boot if ksplash is disabled
Product: [Plasma] plasmashell Reporter: Usarin Heininga <usarinheininga>
Component: generalAssignee: David Edmundson <kde>
Status: RESOLVED FIXED    
Severity: normal CC: katyaberezyaka, nate, plasma-bugs
Priority: HI    
Version: 5.20.90   
Target Milestone: 1.0   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 5.21.1
Sentry Crash Report:

Description Usarin Heininga 2021-01-31 20:43:25 UTC
SUMMARY


STEPS TO REPRODUCE
1. Disable splash.
2. reboot.

OBSERVED RESULT
The system will reboot, but it will take a long time to finish.

the line:
#ExecStartPost=-/usr/lib/qt5/bin/qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage ksmserver in plasma-ksmserver.service is the problem.

ksplash is not running and therefor not registered on dbus. QDbus will hang for a long time before timing out.

Replacing the line with:
ExecStartPost=-/usr/bin/sh -c "[ $(kreadconfig5 --file ksplashrc --group KSplash --key Engine) != none ] && /usr/lib/qt5/bin/qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage ksmserver" fixes the problem.

Using ExecCondition is not an option because that would apply to ExecStart=/usr/bin/ksmserver as well.

The same problem exists in plasma-ksplash-ready.service. Adding ExecCondition=/usr/bin/sh -c "[ $(kreadconfig5 --file ksplashrc --group KSplash --key Engine) != none ] && exit 0 || exit 1" there fixes it.

EXPECTED RESULT

Fast boot

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Ubuntu Hirsute
(available in About System)
KDE Plasma Version: 5.20.90
KDE Frameworks Version: 5.78
Qt Version: 5.15

ADDITIONAL INFORMATION
Comment 1 David Edmundson 2021-01-31 21:31:07 UTC
>QDbus will hang for a long time before timing 

It's a bit more complicated. 
Typically if something is not on the bus it will time out instantly.

Unfortunately we mark ksplash as a fake DBus activatable service to avoid races. It starts a small binary that just sits there blocking until the real name comes up and exits (plasma-waitforname) 

It's that combo that breaks things.
Comment 2 Usarin Heininga 2021-01-31 21:46:30 UTC
In that case a different solution might be more appropriate
One where plasma-waitforname doesn't run for the specific interface when the splash is disabled.
Comment 3 David Edmundson 2021-01-31 22:32:29 UTC
In terms of best long-term solution, I want to drop all of these stages. They're all a mess and rather meaningless. 

There's also the repeated discussion about killing ksplash given how much work we've done on the boot.


In terms of super short fixes; I can apply your patch above, though it's making something that's already a bad hack even longer. Hypothetically does adding an '&' on the end work?
Comment 4 Usarin Heininga 2021-02-01 09:33:18 UTC
Just adding a '&' to the original line doesn't work because systemd doesn't understand shell commands. Changing the line to ExecStartPost=-/usr/bin/sh "/usr/lib/qt5/bin/qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage ksmserver &" works fine. You will get some extra error messages in the log though. Since the whole bootup thing might change in the future I would just use the shell encapsulating with a '&' at the end. The plasma-ksplash-ready.service can stay like it was, it doesn't stall the boot, it just creates some error messages.

Regards
Comment 5 Bug Janitor Service 2021-02-01 14:52:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/625
Comment 6 hchain 2021-02-17 09:56:32 UTC
Git commit e7e49916712d2d8efc65d7da1721eb1d31dc65d6 by Henri Chain, on behalf of David Edmundson.
Committed on 17/02/2021 at 09:53.
Pushed by davidedmundson into branch 'master'.

Move ksmserver's ksplash notifying to ksmserver

Previously the call to ksplash was being emitted by plasma-session. This
isn't used in the systemd startup so it was introduced in a somewhat
messy script.

This script has an issue:

If ksplash is disabled the bus name won't be registered. Typically this
isn't an issue. However to avoid a race condition ksplash registers
itself as being DBus activatable, so that the dbus server holds
dispatching the message.

This combo means ksmserver our unit is considered as not running until
our script times out. This then defers other things in the chain that
depend on ksmserver.

Moving the call into the relevant piece of code into ksmserver unifies
things into a single path and gives us more control.

M  +0    -2    ksmserver/plasma-ksmserver.service.in
M  +7    -0    ksmserver/server.cpp
M  +0    -1    startkde/plasma-session/startup.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/e7e49916712d2d8efc65d7da1721eb1d31dc65d6
Comment 7 David Edmundson 2021-02-17 09:58:32 UTC
Git commit a3f5ac1296e93eefaca1f70d48c6c03c688f3946 by David Edmundson.
Committed on 17/02/2021 at 09:58.
Pushed by davidedmundson into branch 'Plasma/5.21'.

Move ksmserver's ksplash notifying to ksmserver

Previously the call to ksplash was being emitted by plasma-session. This
isn't used in the systemd startup so it was introduced in a somewhat
messy script.

This script has an issue:

If ksplash is disabled the bus name won't be registered. Typically this
isn't an issue. However to avoid a race condition ksplash registers
itself as being DBus activatable, so that the dbus server holds
dispatching the message.

This combo means ksmserver our unit is considered as not running until
our script times out. This then defers other things in the chain that
depend on ksmserver.

Moving the call into the relevant piece of code into ksmserver unifies
things into a single path and gives us more control.


(cherry picked from commit e7e49916712d2d8efc65d7da1721eb1d31dc65d6)

M  +0    -2    ksmserver/plasma-ksmserver.service.in
M  +7    -0    ksmserver/server.cpp
M  +0    -1    startkde/plasma-session/startup.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/a3f5ac1296e93eefaca1f70d48c6c03c688f3946