Bug 435869 - Logout cancelled by ... without asking.
Summary: Logout cancelled by ... without asking.
Status: RESOLVED DOWNSTREAM
Alias: None
Product: ksmserver
Classification: Unmaintained
Component: general (show other bugs)
Version: 5.21.3
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-18 09:51 UTC by leftcrane
Modified: 2021-05-10 14:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description leftcrane 2021-04-18 09:51:16 UTC
SUMMARY

KDE logout (and shutdown) can be "cancelled" by any process without asking. I've experienced this with ss-qt5 and recoll (gui). Googling "KDE logout cancelled by" will yield many other examples going back years. This effectively allows any program to break basic logout functionality.

In the case of recoll gui, the program first cancels the logout without asking, then closes itself. So a second attempt to logout will be successful in this case. Basically it cancels logout immediately and then gets closed like its supposed to, but that point its already late. Very silly behavior.

Programs shouldn't be able to break logout. When something is blocking logout, you should get some kind of "process is preventing logout - [wait] [terminate]" or even a hack like "force logout." The logout process should never be cancelled by random apps, only paused.

Whatever the solution, anything would be better than the current behavior. To the best of my knowledge, other desktops don't have this issue.


There are quite a few bugs about this in the tracker, which reports of eminently closeable apps - like chat and dictionary - being granted the right to cancel the logout without asking the user. Some of these are marked as "FIXED DOWNSTREAM" but when random apps can do this to the session, that becomes a KDE bug irrespective of the problems with downstream.


Operating System: Manjaro Linux
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2
Kernel Version: 5.11.10-1-MANJARO
OS Type: 64-bit
Graphics Platform: X11
Comment 1 leftcrane 2021-04-18 10:00:34 UTC
List of apps happily cancelling logout:

- Clementine music player
- Sartdict - yes a dictionary app!
- A vpn client (ss-qt)
- Recoll A search app gui (but not the underlying process)

Also what about apps like Kate? They still cancel the logout first and ask questions later, right? So if you have an unsaved document in Kate and try to logout, you'll have go back and save it then hit logout again this. That doesn't usable either: even if the app has a good reason for preventing logout, this should be temporary, the logout should proceed after whatever was blocking it has been resolved.
Comment 2 leftcrane 2021-04-18 10:07:36 UTC
Actually Kate's behavior is fine, but obviously it's unrealistic to expect every app to behave perfectly on KDE.
Comment 3 Nate Graham 2021-04-21 18:37:39 UTC
Unfortunately this isn't something we can fix on our side; it's up to apps to have sane behavior when they interrupt the logout sequence. We can't detect when apps are doing behaving in a silly or unfriendly manner to be able to present a UI to the user to ask them what to do. We also can't make apps unable to interrupt logout or else we're risking data loss. If an app wants to interrupt logout for a good reason--say, to display a warning that you need to save unsaved changes--if we block that, the user will lose their data. Such a scenario would be far worse than the annoyance of having to manually quit apps or track down a misbehaving app with stupid logout-cancelation behavior.
Comment 4 leftcrane 2021-04-21 21:47:52 UTC
But the app shouldn't be allowed "cancel" the logout under any circumstances. It could ask the logout process to wait and retry. This would fix the issue with most misbehaving apps, which first angrily cancel the logout and then say "ok whatever, we'll terminate." But then the user has to logout again, and again - however long it takes. 

Why can't the system take care of that keep retrying the logout on its own?
Comment 5 Nate Graham 2021-04-21 21:51:42 UTC
If we make apps unable to cancel logout, then when you logout while an app has unsaved changes, those changes are lost.
Comment 6 leftcrane 2021-04-21 23:32:32 UTC
No app can "cancel" a logout, since that presumes the app has control of the process and not the user. The app can ask the logout process to hold and try again but it can't cancel it. Cause what does that mean? Some stupid app is going to tell me I should never logout? That's absurd.


Apps like Kate don't actually cancel logout, they just ask the process to wait and then retry after the work has been saved. This is how it should be. Apps can ask to retry logout after they finish whatever they are doing but they shouldn't be able to simply abort a process initiated by user.
Comment 7 leftcrane 2021-04-21 23:38:07 UTC
Here's what I would do on my machine. Use notification triggers thankfully available on KDE to re-initiate logout after the app tries to "cancel" to. If it's safe to initiate logout the first time, it's just as safe to initiate it a second time. The second attempt would solve most of the problems because by then the stupid program would have likely closed itself already. This is the behavior I've observed. What's wrong with retrying logout?

So this is the correct behavior, with no downsides. I can fix it on my machine but should the average user be expected to write a script to logout?
Comment 8 David Edmundson 2021-04-21 23:46:40 UTC
> with no downsides.

Surely if you had unsaved changes in kwrite and kept hitting cancel you'd get prompted infinite times?
Comment 9 leftcrane 2021-04-22 00:11:10 UTC
I don't see a problem with that. The user said he want to logout, so that's what they desktop should do.

"Cancel" in a Kate dialog - though again Kate it's the problem here - doesn't mean "cancel the logout." Kate isn't a session manager. The desktop on the other hand *could* give the user the option of explicitly canceling the logout. I think this might actually be how other desktops handle it. In fact, I'll add this to my script.

I've never observed the issue of some random app "cancelling" a logout on any other desktop or platform. And I don't think that's because all the apps there were perfect. IIRC, the other desktops maintain control of the logout process throughout. I've used KDE for so long that I forget what exactly they did but I've never seen a random app "cancel" a logout of its own accord, permanently, other than in KDE. This kind of behavior makes absolutely no sense.
Comment 10 leftcrane 2021-04-22 00:12:09 UTC
> though again Kate it's the problem here

Kate ISN'T the problem here. (typo)
Comment 11 leftcrane 2021-05-09 00:07:30 UTC
Can the decision of whether to cancel the logout be at least given to the user?

Here's a sensible dialog for this situation, and that's how OTHER platforms handle it:

> "App so and so is preventing logout, What do you want to do? 

> [Retry - (timer)] [Abort logout]

That will fix the problem in a safe way. Allowing programs to "cancel" logout at will is actually the most dangerous approach in practice, because it encourages technically illiterate or frustrated users to solve the problem with a hard shutdown. If the software won't comply, they power button will, so that's what the user will do.

I'd appreciate if this bug were reopened. Allowing random apps to cancel logout is unheard of on other platforms, and for good reason. It would be a considered a major bug on Windows.
Comment 12 leftcrane 2021-05-09 00:09:50 UTC
Not sure what resolved downstream means here. The bug hasn't been resolved anywhere, downstream or upstream.