Bug 491130

Summary: Session management loses state between sessions
Product: [Plasma] plasmashell Reporter: Unknown <null>
Component: Session ManagementAssignee: Plasma Bugs List <plasma-bugs>
Status: REPORTED ---    
Severity: normal CC: akontsevich, kairo, KDE, kishore96, natalie_clarius, wenzezlaus
Priority: NOR    
Version: 6.1.4   
Target Milestone: 1.0   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Unknown 2024-08-01 15:20:42 UTC
SUMMARY
After logout or shutdown, when logging in again, session is occasionally not restored correctly.
When multiple windows of an application were open, sometimes they are not restarted.
(This never happened with Plasma 5.27.9 over a period of more than 20 months, but happens roughly in 1 out of 5 re-logins with Plasma 5.27.11 – so the bug was introduced between)

STEPS TO REPRODUCE
Plasma is configured to restore the session from the last logout.

So far no reproducible trigger could be identified – it seems to happen randomly on several different systems (with the same SW versions).

OBSERVED RESULT
After logout sometimes multiple windows of several programs – observed with Dolphin, Konsole (and some tabs of Firefox, but that might be an uncorrelated issue) – are not restored. Instead either no window or a single window of the program is opened (at the default location – i.e. user home)

Funnily: If then you logout immediately and then re-login, often the windows are restored correctly as you left them with the session second to last … (nice bug – bug, because it should have restored the incomplete state of the previous session – but recovers the state of the penultimate (which the previous session should have had recovered) …

EXPECTED RESULT
KDE/Plasma correctly and reliable recovers the window states of the previous session.
(as can and is expected from X11 window managers since the days of "olvwm" – 35 years ago …)

SOFTWARE/OS VERSIONS
Operating System: openSUSE Leap 15.6
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Kernel Version: 6.4.0-150600.23.14-default (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i5-10210U CPU @ 1.60GHz
Memory: 7.6 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics

ADDITIONAL INFORMATION
–
Comment 1 Kishore Gopalakrishnan 2024-08-04 17:00:57 UTC
I also seem to have a similar issue. When this happens again, can you check if you have messages like the following in your system logs?

```
$ journalctl -b -0 | grep "Session management error"
Aug 04 22:00:34 kishore-thinkpad-e495 kate[4510]: Qt: Session management error: Authentication Rejected, reason : MIT-MAGIC-COOKIE-1 authentication rejected
... [many more messages like this]
```

Usually this authentication works fine (and the session restores properly), but sometime I get this. Perhaps some sort of race condition?
Comment 2 Unknown 2024-08-06 14:30:43 UTC
(In reply to Kishore Gopalakrishnan from comment #1)
> I also seem to have a similar issue. When this happens again, can you check
> if you have messages like the following in your system logs?
> 
> ```
> $ journalctl -b -0 | grep "Session management error"
> Aug 04 22:00:34 kishore-thinkpad-e495 kate[4510]: Qt: Session management
> error: Authentication Rejected, reason : MIT-MAGIC-COOKIE-1 authentication
> rejected
> ... [many more messages like this]
> ```

Good hint!

Similar, but slightly different, messages here – on all machines affected, one example of many identical:

2024-08-06T01:12:45.845617+02:00 systemname kscreenlocker_greet[25446]: Qt: Session management error: networkIdsList argument is NULL


> Usually this authentication works fine (and the session restores properly),
> but sometime I get this. Perhaps some sort of race condition?

I suspect a bug in the newly implemented option to explicitly manually save and restore sessions …

(Which IMHO is conceived quite sub-optimally: 
The save option is only present when the system is configured to only manually restore sessions – but you have to restart your session to have the "save option" turn up :-(

Much better would have been IMHO:
You always have the option to manually save your session state with a name of your choice.
The automatic saving of the session at logout (name "last session") can be toggled.
If there is more than one saved and named session state available, you are offered the choice …
)
Comment 3 Kishore Gopalakrishnan 2024-08-08 04:46:40 UTC
It seems my bug is different from yours, then. I have now opened a separate report (bug 491421)
Comment 4 Aleksey Kontsevich 2024-08-30 20:28:38 UTC
Have same in 6.1.4. Redirected here from https://bugs.kde.org/show_bug.cgi?id=487912