Bug 445862 - konsole: unclean shutdown/broken session restore
Summary: konsole: unclean shutdown/broken session restore
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 21.04.3
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-21 12:59 UTC by Dave Flogeras
Modified: 2023-03-07 05:25 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Flogeras 2021-11-21 12:59:12 UTC
See also downstream https://bugs.gentoo.org/819459

More information has been collected there.

The general idea is that lately, for some users, konsole windows do not shutdown properly when logging out (they will remain on the screen during the logout process then eventually get reaped).  When using the plasma feature "start with last session", those same konsole windows do not get re-opened when logging back in.  I have also noticed that some konsoles that I have had running for months (prior) to this behaviour do in fact close & restore properly; this bug just seems to affect newly opened konsoles.

We have been unable to narrow it down further, other than newly created users with default settings do not observe this behaviour, but some setting or combination of settings makes it happen.


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Gentoo
(available in About System)
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.5
Qt Version: 5.15.2-r10

ADDITIONAL INFORMATION
Observed with konsole 21.04.3, 21.08.2, 21.08.3
Comment 1 Peter Humphrey 2022-04-12 04:09:47 UTC
After watching it many times, I think this is what happens: Konsole receives a shut-down command from SDDM and starts acting on it. The four sides of the frame disappear, but then the code hangs before it can clear the contents of the window. Konsole never reaches the spot where it acknowledges the shutdown to SDDM, which therefore does not add that instance of Konsole to its list of programs to run at the next login.

This does not happen inevitably in a newly created user account, but if it does happen once to a particular window, it will always happen to that window in the future, as though the code were modifying itself.

Secondly, I added the URL of the original Gentoo bug in the See Also box here but was told it was not a valid bug URL. It certainly is valid; it's https://bugs.gentoo.org/819459.
Comment 2 Dave Flogeras 2022-12-04 15:51:44 UTC
I found a workaround, at least for my specific machine.

It seems like on this machine, when I set up my konsole keyboard shortcut, I just assigned a key-combo to the shortcut under Session->Shortcuts->Custom Shortcuts->KMenuEdit->Konsole->Trigger.  This shortcut I think is created by default.

On other machines, I made a new custom group, then added a newly created shortcut by clicking edit->new->global shortcut->command/url and filling it in.

What I notice is that if you go into /proc/`pidof ksmserver/fd and inspect the open files, starting console with the first shortcut does not seem to notify ksmserver of its presence, but using the "from scratch" shortcut seems to make a new socket to ksmserver for each konsole.  I guess if konsole doesn't tell ksmserver about itself it cannot be queried for session management at logout.

Not sure of the how or why, but it seems to fix/work around the issue here.  I am also sure this used to work, and I only set the short cut up when I bought the laptop nearly three years ago.  Hope it helps someone else get un-stuck.
Comment 3 Eric Hoffman 2023-03-07 05:25:28 UTC
That's a very good lead...

Indeed, I do have a shortcut to start Konsole (By going to the menu editor, for the konsole app, and I set CTRL-ALT-T to start Konsole).
If I start a few Konsole by pressing CTRL-ALT-T, then on restart, they don't get restored.
If I start Konsole by going to the menu, clicking Konsole (from the main KDE menu), then on restart, those instances are restored.

When I close the session (logout), I can see all the instances that I manually started (from KDE menu) closing promptly.  All the instances I started with CTRL-ALT-T, I see the frame border disappear, but the client area stay there for half a second (before presumably getting killed).