Bug 454726 - On X11, ksmserver does not store certain apps' session information
Summary: On X11, ksmserver does not store certain apps' session information
Status: RESOLVED WORKSFORME
Alias: None
Product: plasmashell
Classification: Plasma
Component: Session Management (other bugs)
Version First Reported In: 5.24.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-02 07:42 UTC by Ilab Sentuser
Modified: 2025-02-08 03:47 UTC (History)
5 users (show)

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


Attachments
ksmserver file (2.71 KB, text/plain)
2022-06-02 07:42 UTC, Ilab Sentuser
Details
session log file (1.04 KB, text/x-log)
2022-06-02 07:42 UTC, Ilab Sentuser
Details
compressed session folder contents (3.21 KB, application/vnd.rar)
2022-06-02 07:43 UTC, Ilab Sentuser
Details
ksmserver file (3.20 KB, text/plain)
2022-06-14 11:35 UTC, Khanich
Details
xorg-session-log (1.30 KB, text/x-log)
2022-06-14 11:35 UTC, Khanich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ilab Sentuser 2022-06-02 07:42:02 UTC
Created attachment 149387 [details]
ksmserver file

SUMMARY
With restore last session option selected in system settings when leaving the system (log out, reboot, shutdown) the information of certain apps is not stored for its later restoration. The fail seems to be during the process of saving the information and not while trying to restore the applications. More details in the additional info section.

STEPS TO REPRODUCE
1. Open the affected app (kate, dolphin)
2. Log out/Reboot/Shutdown
3. Login to your account

OBSERVED RESULT
The affected apps do not restore while others do.

EXPECTED RESULT
The apps should be restored normally.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Archlinux
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4

ADDITIONAL INFORMATION
At some point in the past (couple of days ago) all previous apps where restored correctly. Suddenly dolphin stopped being restored on session start. No update to dolphin or any other component of plasma occurred during those days as far as I remember. After some tinkering and information gathering I checked the information at: ~/.config/session/ and ~/.config/ksmserverrc to figure out the problem, under the session directory I found information about the apps that are where to be restored. In the ksmserverrc file I found entries for most apps but not dolphin. After some tinkering and enabling debugging on ksmserver by following steps provided on other bug reports I proceeded to check the journal and check the data on session folder. Tried changing options from "restore last session" to "restore manually saved session" after a logout/login cycle everything worked. Next reboot, dolphin failed to be restored again, but now, kate fails also. After deleting content on the session folder (backed up first in case it is needed) y deleted all content and did the same with the file ksmserverrc. Proceeded to reboot, after login I still se the same behavior (kate and dolphin are not restored) checked that there are no entries for neither on ksmserverrc and there was no data generated for neither on session folder. As such, I would say that data is not properly being saved and as such restoration is not currently possible.
I also consulted information on bugs: 442380, 453471, 404318. In my case no encrypted drives are present, nor internal nor external. While it could be a problem with dolphin not saving its state correctly, kate started to exhibit the same behavior so I would guess a more general problem is present with ksmserver instead. I also tried saving the session manually from the option in the leave menu when the appropriate option is selected on settings and doing so using the terminal. In all instances the problem can be reproduced.
Comment 1 Ilab Sentuser 2022-06-02 07:42:52 UTC
Created attachment 149388 [details]
session log file
Comment 2 Ilab Sentuser 2022-06-02 07:43:30 UTC
Created attachment 149389 [details]
compressed session folder contents
Comment 3 Nate Graham 2022-06-02 17:01:53 UTC
Are you using the Wayland session, or X11?
Comment 4 Ilab Sentuser 2022-06-03 09:08:25 UTC
A crucial piece of information that I missed, I am using X11. 

Also, currently Kate and Dolphin capability to being restored has returned, as per my testing it seems to be related to the way in which the system is terminated, I am still working on it, but I think that there is a difference in the way sessions are saved when shutting down/rebooting/logging out that has a significant effect on how/why ksmserver sometimes succeeds in saving their session information. Might be related to timeouts before killing those processes. Can't be sure yet.
Comment 5 Khanich 2022-06-14 11:33:46 UTC
Hello,

I actually have the same (or similar) problem, sometimes it saves the session, sometimes it doesn't.

It's also not always every application which gets saved.

And Flatpak apps don't seem to work at all.

Furthermore, in the "kwin_saved_at_previous_logout_" file, even though it wasn't open, I find gedit. Although yes, the "last change" time was the last logout. (I installed gedit to find out if only Qt apps gets saved, but that worked, so I closed it again. Then I noticed that even Qt apps don't work all the time.)

I use openSUSE Tumbleweed with X11 session.
Comment 6 Khanich 2022-06-14 11:35:04 UTC
Created attachment 149675 [details]
ksmserver file
Comment 7 Khanich 2022-06-14 11:35:34 UTC
Created attachment 149676 [details]
xorg-session-log
Comment 8 Eric Hoffman 2023-03-07 05:43:12 UTC
I actually posted a comment to an issue for the Konsole app, but I think that what I found is more general, as this seems to affect multiple applications.
What I found is that for applications which I created keyboard shortcut, if I start those applications using the shortcut I programmed, then those applications are not restored on restart.

Example, I go to KDE menu editor, and set the Konsole app to start with keyboard shortcut "CTRL-ALT-T".  And I set Dolphin to start with "Meta-E" (Win-E).

I then start a few instances of Konsole and Dolphin using CTRL-ALT-T and Meta-E, and I start a few more instances by going directly to the KDE menu and starting those applications from the KDE menu.

I logout, log back in.

Then, all the instances started from keyboard shortcut are not restored.  While all the ones started manually does restore properly.

What I noticed also during logout, all the applications started from the main menu (the ones that get properly saved/restored) closed promptly, while the ones started from keyboard shortcut, I saw the window frame disappear, while the client area stayed on screen for half a second (before presumably getting terminated).
Comment 9 Eric Hoffman 2023-03-07 05:57:09 UTC
To add, using ps -afx, I can see that the applications I start manually are created with process hierarchy

sddm-->sddm-helper-->startplasma-x11-->plasma_session-->xembedsniproxy-->plasmashell--><app>

While the ones I start from keyboard shortcut has the process hierarchy

systemd--><app>

Example "ps -aux" output (shoing just the tree portion):

/usr/bin/sddm
 \_ /usr/lib/sddm/sddm-helper --socket /tmp/sddm-authea9cb49f-0c5e-4275-8196-80d0
     \_ /usr/bin/startplasma-x11
         \_ /usr/bin/plasma_session
             \_ /usr/bin/xembedsniproxy
             \_ /usr/bin/plasmashell
                 \_ /usr/bin/konsole
                     \_ /bin/bash

/usr/lib/systemd/systemd --user
 \_ /usr/bin/konsole
 |   \_ /bin/bash
 |       \_ ps -afx
 \_ /usr/bin/dolphin
Comment 10 Eric Hoffman 2023-03-07 17:39:32 UTC
Another point I noticed.

kglobalaccel5 is under systemd process.  What I think is happening is that when I press a shortcut key (which I guess is set as a global accelerator), the application is launched by kglobalaccel5, and detached from it (it's parent PID becomes systemd).  That's why you see those hotkey started application under systemd.

When closing the plasma session, I guess that the affected applications just does not receive the message to store the session information.

This is just a theory, I don't really know how plasma is handling sessions start/stop.
Comment 11 Khanich 2023-04-15 19:50:27 UTC
(How did I not get an email about it? I am in the CC list. Anyway.)

I can't really confirm your observation about only non-keyboard started applications restoring, 

On my end I always start Firefox via the task bar. It never gets restored.
Applications like Dolphin and Konsole, which I always start via shortcut, get restored sometimes, but very rarely and never predictable.
Still an X session btw.
Comment 12 Ilab Sentuser 2023-04-19 16:50:50 UTC
Hello,
I missed the notification or something so I am late for this. But I think I can confirm what Eric Hoffman said about applications started with a shortcut not being restored and ones being started from the menu being restored correctly. Just tried it twice and yup. I can't recall now but that also makes sense why sometimes they do restore, probably times I started them from the menu instead of shortcuts. Will try and see if I can find something in the code about this problem that I can discern, maybe check his theory. Will try to do it this weekend. Will update if I come up with anything as I had already surrendered with this issue, but now I have hope hahaha.
Regards.
Comment 13 TraceyC 2025-01-09 22:31:55 UTC
Thank you for the bug report. Unfortunately we were not able to get to it yet. Can we ask you to please check if this is still an issue with either Plasma 5.27.11 (the current LTS version) or Plasma 6.2.4 (the latest released version)?

If you can still reproduce the bug, please change the Status to "CONFIRMED". Thanks.
Comment 14 Bug Janitor Service 2025-01-24 03:46:59 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 15 Bug Janitor Service 2025-02-08 03:47:32 UTC
๐Ÿ›๐Ÿงน This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.