Bug 497520 - On X11, session management loses state between sessions for certain apps
Summary: On X11, session management loses state between sessions for certain apps
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Session Management (show other bugs)
Version: 6.2.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: regression, X11-only
: 501973 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-12-15 21:01 UTC by Aleksey Kontsevich
Modified: 2025-03-27 13:19 UTC (History)
5 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 Aleksey Kontsevich 2024-12-15 21:01:41 UTC
Issues still not fixed in Bug 491130 and Bug 487912:
- https://bugs.kde.org/show_bug.cgi?id=487912#c61
- https://bugs.kde.org/show_bug.cgi?id=491130#c5

SUMMARY
- with Akregator - happens after session restore: Bug 494071
- with Chromium: if it has multiple windows, after session restore it opens more (empty) windows than it had on logout.
- Chromium windows size on login is different than on logout.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20241213
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.1
Kernel Version: 6.11.8-1-default (64-bit)
Graphics Platform: X11
Comment 1 Nate Graham 2024-12-16 18:15:54 UTC
Please describe the actual issue rather than saying "the issue over there in that other bug report isn't fixed".
Comment 2 Aleksey Kontsevich 2024-12-16 18:26:17 UTC
(In reply to Nate Graham from comment #1)
> Please describe the actual issue rather than saying "the issue over there in
> that other bug report isn't fixed".

I described all in details multiple times! See #1 comment.

Another bug on session state loss:
- If a window is minimized on logout it should be minimized as well on login (on session restore).
Comment 3 Nate Graham 2024-12-16 19:04:45 UTC
This isn't helpful. You're just mentioning random likely unrelated issues here with no context or details, which isn't the proper way to report bugs.

Please read through https://community.kde.org/Get_Involved/Issue_Reporting and then try again.
Comment 4 Aleksey Kontsevich 2024-12-16 19:33:15 UTC
(In reply to Nate Graham from comment #3)
> This isn't helpful. You're just mentioning random likely unrelated issues

Not random: they happen ALL the time: ON EVERY session save/restore  - on every logout/login.

> here with no context or details, which isn't the proper way to report bugs.

What other context do You need?! Windows states/behavior are different than on logout. And happens opnly on session restore. Does not happen in other conditions.
 
> Please read through https://community.kde.org/Get_Involved/Issue_Reporting
> and then try again.

It is useless. I can't guess Your caprices: You have not fixe the issues in th eprevious reposrt and said to create a bug - I did. Now You want something else. I can't create bugs more and more until You happy.

I explained all in details (read above):

>SUMMARY
- with Akregator - happens after session restore: Bug 494071
- with Chromium: if it has multiple windows, after session restore it opens more (empty) windows than it had on logout.
- Chromium windows size on login is different than on logout.
- If a window is minimized on logout it should be minimized as well on login (on session restore).

Just say the truth: You do not want to fix the bugs!!!
Comment 5 Nate Graham 2024-12-16 19:40:09 UTC
The truth is that I want you to open a proper bug report with steps to reproduce and details for one specific issue at a time so each can be properly investigated. If you aren't willing or able to do that, then there's no chance any of these issues can be investigated and fixed. Right now you're mentioning four separate issues in one bug report, each with no steps to reproduce or helpful context. This isn't the way to successfully report bugs.
Comment 6 Aleksey Kontsevich 2024-12-16 19:45:56 UTC
(In reply to Nate Graham from comment #5)
> The truth is that I want you to open a proper bug report with steps to
> reproduce and details for one specific issue at a time so each can be
> properly investigated. If you aren't willing or able to do that, then
> there's no chance any of these issues can be investigated and fixed. 

Steps are very simple and mentioned in the title: "Session management loses state between sessions":
1. Run Akregator and Chromium
2. Open multiple Chromium windows with multiple tabs
3. Restart PC or Plasma
4. On the next login You'll see all the issues I mentioned (I created separate one for the Akregator) - it is very simple.

>Right now you're mentioning four separate issues in one bug report, each with no
> steps to reproduce or helpful context. 

Not separate! Previous issues (with the same topic) also stated bugs with DIFFERENT applications, but bug is the same: not proper, not complete session restore.
Comment 7 Nate Graham 2024-12-17 15:47:14 UTC
Ok, re-opening. It's not clear to me if this is a general issue in our code, or some kind of incompatibility with just those apps. I'll let smarter people then me figure it out.
Comment 8 Aleksey Kontsevich 2024-12-18 11:02:08 UTC
Hmm, Chromium restored correctly today 1st time. Akregator - not.
Comment 9 Aleksey Kontsevich 2024-12-18 12:55:13 UTC
(In reply to Aleksey Kontsevich from comment #8)
> Hmm, Chromium restored correctly today 1st time. Akregator - not.

No, checked again: still happens. So all the bugs are present.

>- If a window is minimized on logout it should be minimized as well on login (on session restore).

BTW, this one happens with any application - so this is definitely a session restore bug. Not happens only with apps minimized to tray on logout.
Comment 10 Aleksey Kontsevich 2025-02-01 22:42:54 UTC
Found another application not restored correctly: LibreOffice does not start on next login.
Comment 11 Aleksey Kontsevich 2025-02-14 10:19:01 UTC
Another case: application installed via snap is not restored at all (some Qt app for example).
Comment 12 TraceyC 2025-03-25 21:49:01 UTC
*** Bug 501973 has been marked as a duplicate of this bug. ***
Comment 13 TraceyC 2025-03-25 21:49:49 UTC
Some details from bug 501973

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.12
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13

ADDITIONAL INFORMATION
Manual fix: 
Snap applications are saved to the Block "LegacySession" in .config/.ksmserverrc, but the command saved is not working properly/as intended. Manually changing the command to the correct path/to/bin (evaluated by the which command) leads to the proper behaviour of the restore session, but is conceptually only a solution for restoring manually saved sessions.
Detailed steps for manual fix: 
1. Manually save the session as usual 
2. Open .config/.ksmserverrc. It should contain something like this: 
 [LegacySession: saved by user]
 clientMachine1=localhost
 command1=thunderbird-esr
 count=1
3. Correct command1 to actual path/to/bin, e.g.: 
 [LegacySession: saved by user]
 clientMachine1=localhost
 command1=/usr/bin/thunderbird
 count=1
4. Save file and reboot -> Restore session now works.
Comment 14 Aleksey Kontsevich 2025-03-25 22:35:48 UTC
(In reply to TraceyC from comment #13)
> 1. Manually save the session as usual 

BTW, how to do this? No item in the main menu.
Comment 15 TraceyC 2025-03-26 16:08:47 UTC
(In reply to Aleksey Kontsevich from comment #14)
> (In reply to TraceyC from comment #13)
> > 1. Manually save the session as usual 
> 
> BTW, how to do this? No item in the main menu.

If the Desktop Session settings are set to "When session was manually saved", there will be a "Save Session" in the app launcher menu
Comment 16 Aleksey Kontsevich 2025-03-26 17:11:29 UTC
(In reply to TraceyC from comment #15)
> (In reply to Aleksey Kontsevich from comment #14)
> > (In reply to TraceyC from comment #13)
> > > 1. Manually save the session as usual 
> > 
> > BTW, how to do this? No item in the main menu.
> 
> If the Desktop Session settings are set to "When session was manually
> saved", there will be a "Save Session" in the app launcher menu

Ah, yes, looked for it in wrong place: it is next to Power Off, Reboot, etc. Thanks!
Comment 17 Jonas E 2025-03-27 00:00:30 UTC
(In reply to TraceyC from comment #13)
> Some details from bug 501973

Additional (Hacky) fix for restoring snap apps after logout (default behaviour), USE AT YOUR OWN DISCRETION
1. Get the command name from the snap package either by 
  - logging out and checking .config/ksmserverrc, or by 
  - opening the snap app, and searching through the output of 'xwininfo -tree -root', which list all open x11 windows and contains the WM_COMMAND set for the leader window) 
2. Now, the hacky part: create a symlink with the command name to the actual correct command (has to be on your path, so that it is found for execution) -> e.g. for the snap firefox on my machine: 'ln -s /usr/bin/firefox firefox_firefox'

Result: We manually resolve the wrong command and restore correct behaviour.
Comment 18 Jonas E 2025-03-27 00:50:42 UTC
Both of the fixes DO NOT WORK FOR EVERYTHING - rather they seem to specifically fix issues with Mozilla setting strange WM_COMMAND Atoms in X11 
Other snap apps set WM_COMMAND to the actual command, and restore correctly (e.g. GIMP)

Akregator and Konsole Sessions NEVER RESTORE, and for them nothing is written in  ksmserverrc at all


Code hints for the snap/Mozilla issue:
ksmserver seems to fallback to the legacySession style of saving for (at least some, e.g. Mozilla) snap apps.
On git, this is in the plasma-workspace/ksmserver/legacy.cpp.

For the save, the window WM_COMMAND is retrieved (with KSMServer::windowWmCommand; legacy.cpp l. 295ff.
- Unfortunately, the WM_COMMAND X11 Atom set by snap/Mozilla is wrong (firefox_firefox, thunderbird-esr), as in it does not match the executable name -> the window is not restored.

There are already some changes made for Mozilla, maybe it is possible to add the new miss-reportings of WM_COMMAND from snap-based Mozilla there too
Comment 19 Aleksey Kontsevich 2025-03-27 13:19:53 UTC
BTW, session saved manually restored better than on exit: all the apps are present, and snap apps are restored for example.