Bug 493665 - kate losts session after restore plasma session
Summary: kate losts session after restore plasma session
Status: REOPENED
Alias: None
Product: kate
Classification: Applications
Component: sessions (show other bugs)
Version: Git
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: qt6, wayland
Depends on:
Blocks:
 
Reported: 2024-09-25 23:43 UTC by Piotr Mierzwinski
Modified: 2024-11-18 08:40 UTC (History)
4 users (show)

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


Attachments
kate lost session (18.57 KB, image/png)
2024-09-26 22:01 UTC, Piotr Mierzwinski
Details
missing recent files (35.47 KB, image/png)
2024-09-26 22:02 UTC, Piotr Mierzwinski
Details
kate-session-no_docs (13.34 KB, image/png)
2024-10-24 21:02 UTC, Piotr Mierzwinski
Details
multiply "Untilted" (14.51 KB, image/png)
2024-10-27 00:14 UTC, Piotr Mierzwinski
Details
kate - "Manage Sessions" (28.85 KB, image/png)
2024-10-27 00:31 UTC, Piotr Mierzwinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2024-09-25 23:43:31 UTC
SUMMARY
One day I prepare my session ("mySession2), so open two files and one "untilted"(where I put something). Happens update of system. I do it (as installation after restart), power off. Next day I login to Plasma, Kate starts but without opened files. To be clear there is only couple empty "untilted". BTW. Option in menu "File -> Open recent" is disabled (because empty list). This is really annoying, because every day or max evey 2 days I need to open again the same files.

STEPS TO REPRODUCE
1.  Start Kate
2. Open two text files
3. Click "New" to have new untilted document
4. Put something into new document
5. Save as session "mySession2"
6. Make update
7. Make restart of PC

OBSERVED RESULT
No files opened which were saved in session

EXPECTED RESULT
Files saved in session should be opened

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 6.1.90
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
Neon unstable edition
Comment 1 Piotr Mierzwinski 2024-09-26 22:01:39 UTC
Created attachment 174123 [details]
kate lost session
Comment 2 Piotr Mierzwinski 2024-09-26 22:02:12 UTC
Created attachment 174124 [details]
missing recent files
Comment 3 Piotr Mierzwinski 2024-10-02 20:40:24 UTC
I thought it has fixed already, because through few days (I think 3 Kate was restoring the session). Unfortunately today (fourth day) I found no  documents opened. In documents view I found only one empty "untilted" and recent option is disabled (because the list is empty).
Therefore I consider that restore session in Kate doesn't work well, for sure it is not reliable.
Comment 4 Waqar Ahmed 2024-10-03 12:49:19 UTC
Need an easier way to reproduce this.

When this happens next, can you check what's in your ~/.local/share/kate/stash/SESSION_NAME_HERE directory.
Comment 5 Piotr Mierzwinski 2024-10-04 10:19:47 UTC
Today, after login to Plasma I met no restored session (and no recent) in Kate (is present only empty "untilted").

$ pwd
piotr@Dell:/home/piotr/.local/share/kate/stash/mySession2.katesession

piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ls -l
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr  18 paź  4 02:06 'Document 2'
-rw-rw-r-- 1 piotr piotr  95 paź  3 00:35 'Document 2~'
-rw-rw-r-- 1 piotr piotr  13 wrz 19 02:33 'Document 3'
-rw-rw-r-- 1 piotr piotr 364 wrz 19 02:32 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

BTW. Documents in stash don't look like those I had opened recently. It looks like some old state of session.

To be clear.
At October, 2-nd (so when sent last post) I met no restored session in Kate, despite in title bar was name of my session, so I opened again documents I usually work with. Today again the same situation - no restored session in Kate.
Only on activity I've done was updating one document (and save)  - it was normal file (not untilted).
Comment 6 Waqar Ahmed 2024-10-04 11:26:29 UTC
How do you quit Kate? Do you quit it even?
Comment 7 Piotr Mierzwinski 2024-10-05 21:26:47 UTC
(In reply to Waqar Ahmed from comment #6)
> How do you quit Kate? Do you quit it even?

No, I don't quit Kate manually.
Comment 8 Piotr Mierzwinski 2024-10-05 21:29:05 UTC
> How do you quit Kate? Do you quit it even?

No, I don't quit Kate manually.
Plasma close all running application. I use restore session of Plasma, so why I would need to quit Kate manually.
Comment 9 Waqar Ahmed 2024-10-06 13:01:45 UTC
> why I would need to quit Kate manually

because it might not quit correctly and then you risk loosing your session data, like the stashed untitled documents that you keep loosing
Comment 10 Piotr Mierzwinski 2024-10-07 20:47:26 UTC
(In reply to Waqar Ahmed from comment #9)
> > why I would need to quit Kate manually
> 
> because it might not quit correctly and then you risk loosing your session
> data, like the stashed untitled documents that you keep loosing

Anyway this is bug, IMHO. Not sure if in Kate or in "restore session", but bug.
I don't remember if this works well in X11 and this is only issue in Wayland session, or also in X11 works not well. Tell me please if you know.

And please, I don't want to remember everyday to close Kate to don't lose the session, if I have (in Plasma) option "restore session" turned on.
IMHO manual quit is like going to back to the past, whereas Plasma/KDE is adverted like modern environment :/.

BTW. I'm waiting till real restore session will be implemented in Plasma, because current is, let say, clumsy.
Comment 11 Waqar Ahmed 2024-10-08 05:56:07 UTC
> Anyway this is bug, IMHO

Kind of, yeah. IIRC we don't save untitled documents (lets call them "stash docs") periodically. So this needs to be done. Our session is saved every 5 seconds whenever a document changes, so we just need to save "stash docs" as well.

This doesn't have anything to do with x/wayland etc.
Comment 12 Piotr Mierzwinski 2024-10-08 20:35:17 UTC
(In reply to Waqar Ahmed from comment #11)
> > Anyway this is bug, IMHO
> 
> Kind of, yeah. 
For me without a doubt this is a bug. Kate losts session randomly if user don't quit it (Kate) manually.
In my session I have 2 regular files and one "untilted". The files from my subdirectory "mySession2.katesession" doesn't reflect files what usually I have open. I open my 3 files in mentioned session, it (session) lives couple days and disappears.
BTW. Today Kate again lost session. Please consider that such thing doesn't happen in Notepad++ (working on Windows), or I didn't meet it yet and I use it in my job since dozen of a years.

> IIRC we don't save untitled documents (lets call them "stash docs") periodically. 
> So this needs to be done. Our session is saved every 5
> seconds whenever a document changes, so we just need to save "stash docs" as
> well.
Yes, I agree. I have this option turned on (save every 5 sec.), but seems to session as is seems to be incorrectly saved/or not saved if Kate is stopped/killed by Plasma.
 
> This doesn't have anything to do with x/wayland etc.
I've heard/read somewhere some times ago (maybe some kde blog) that the issue coming from plasma, which kill Kate in moment of shutdown/restart. And is hard to support this and then save session.
Comment 13 Waqar Ahmed 2024-10-08 20:57:12 UTC
> I've heard/read somewhere some times ago (maybe some kde blog) that the issue coming from plasma, which kill Kate in moment of shutdown/restart. And is hard to support this and then save session.

That might be true.

I will try to improve the stability in the coming days, it would be great if you can rigorously test this. We need to make this feature stable and reliable enough for daily use. Otherwise the option is totally useless.
Comment 14 Christoph Cullmann 2024-10-12 16:56:59 UTC
The full stashing feature is not that well tested.
In a perfect world me would just always create a dummy file for untitled stuff. Them we even would have swap files for crash recovery.
Comment 15 Bug Janitor Service 2024-10-15 14:18:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1620
Comment 16 Christoph Cullmann 2024-10-17 10:09:26 UTC
Git commit 519037af35316007d8aba5424d720abc08390f93 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 17/10/2024 at 10:05.
Pushed by cullmann into branch 'master'.

include stash docs when auto saving

M  +0    -1    apps/lib/kateapp.cpp
M  +0    -2    apps/lib/katemainwindow.cpp
M  +5    -0    apps/lib/session/katesessionmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/519037af35316007d8aba5424d720abc08390f93
Comment 17 Piotr Mierzwinski 2024-10-23 22:56:13 UTC
Sorry, but this still doesn't work.
I had created a session. Today I found two "Untilted" (second one I could even not close by close button, so I closed first one).
I opened  two regular files, and two "Untilted" where I put some text. I made update, restarted PC, logged in to Plasma and found Kate with one empty "Untilted", so seems to be worse than earlier.

I'm not sure if the fix made at 2024-10-17 was applied in my system before today test.  I don't know how to check this. I just update system every day.

piotr@Dell:~$ cd /home/piotr/.local/share/kate/stash/mySession2.katesession
piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ll
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr  84 paź 24 00:37 'Document 2'
-rw-rw-r-- 1 piotr piotr 187 paź 24 00:37 'Document 2~'
-rw-rw-r-- 1 piotr piotr  59 paź 24 00:37 'Document 3'
-rw-rw-r-- 1 piotr piotr  13 paź 24 00:37 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content), what I left before restart of PC. And unfortunately they were not restored. As I said I met Kate with one empty "Untilted".
Comment 18 Waqar Ahmed 2024-10-24 03:21:14 UTC
Did you check whether kate had opened the needed session, maybe it was some other session? We save the session every ~5 seconds WHENEVER a new doc is created or closed so I can't see why its failing.

Why this happens now is beyond me atm, can't see why it would fail.
Comment 19 Waqar Ahmed 2024-10-24 03:31:38 UTC
> Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content),

If the content is there then can we say that there was no content loss?
Comment 20 Piotr Mierzwinski 2024-10-24 21:01:34 UTC
(In reply to Waqar Ahmed from comment #18)
> Did you check whether kate had opened the needed session, maybe it was some
> other session? We save the session every ~5 seconds WHENEVER a new doc is
> created or closed so I can't see why its failing.

I can see session name in title bar, so I'm sure that Kate opened correct one. I will attach screenshot.
Yesterday I did the same what at the day before yesterday, and result was the same - I met "mySession2" as empty.

piotr@Dell:~$ cd /home/piotr/.local/share/kate/stash/mySession2.katesession
piotr@Dell:~/.local/share/kate/stash/mySession2.katesession$ ll
total 28
-rw-rw-r-- 1 piotr piotr  20 wrz 19 02:32 'Document 0'
-rw-rw-r-- 1 piotr piotr 152 wrz 19 02:32 'Document 0~'
-rw-rw-r-- 1 piotr piotr 306 paź 24 01:56 'Document 2'
-rw-rw-r-- 1 piotr piotr  84 paź 24 01:56 'Document 2~'
-rw-rw-r-- 1 piotr piotr  59 paź 24 00:37 'Document 3'
-rw-rw-r-- 1 piotr piotr  13 paź 24 00:37 'Document 3~'
-rw-rw-r-- 1 piotr piotr 122 sie 31 03:41 'Document 4'

And again 'Document 2' and 'Document 3' have correct content, only have not been reopened.
BTW.
Maybe session should be also saved at the moment when Kate is closed manually and when is killed, otherwise something could be lost.

> Why this happens now is beyond me atm, can't see why it would fail.
Maybe you could add some more debug messages (triggered on some env.variable), or even you could send binary and I could run it and send you such report.
Comment 21 Piotr Mierzwinski 2024-10-24 21:02:02 UTC
Created attachment 175197 [details]
kate-session-no_docs
Comment 22 Piotr Mierzwinski 2024-10-24 21:03:05 UTC
(In reply to Waqar Ahmed from comment #19)
> > Please consider that "Document 2" and "Document 3" are the my both "Untilted" (I checked content),
> 
> If the content is there then can we say that there was no content loss?

Yes, only documents were not opened in the restored session.
Comment 23 Piotr Mierzwinski 2024-10-27 00:14:49 UTC
Created attachment 175261 [details]
multiply "Untilted"

Couple days ago I reported lost session in Kate. Next day "Documents" view was empty, or actually one was present only one "Untilted", today I have several "Untilted" ("Untitled (2)", "Untitled (3)"...) - check attached screenshot "multiply "Untilted", so seems appearing several "Untilted", after restart of Kate is still not fixed. This is another case for Bug 468573, where user quit Kate manually and here Plasma kill Kate and restore it.
Please notice I start my PC every day, today (Saturday) I started twice.
Comment 24 Piotr Mierzwinski 2024-10-27 00:31:46 UTC
Created attachment 175262 [details]
kate - "Manage Sessions"

BTW. In "Manage Sessions" I cannot remove "mySession2". Button "Delete" is from some reason not available (is "grayed"). Before I opened "Manage Sessions" I closed all duplicated Untilted (left one).
Comment 25 Piotr Mierzwinski 2024-10-27 00:37:56 UTC
(In reply to Piotr Mierzwinski from comment #24)
> Created attachment 175262 [details]
> kate - "Manage Sessions"
> 
> BTW. In "Manage Sessions" I cannot remove "mySession2". Button "Delete" is
> from some reason not available (is "grayed"). Before I opened "Manage
> Sessions" I closed all duplicated Untilted (left one).

Ok. I understand. Because this is currently opened.
I removed that session, after I created and opened another one "mySession3". And here opened 3 documents: two regular files and one Untilted. I will see tomorrow (Sunday) if session will be restored.
Comment 26 Piotr Mierzwinski 2024-10-27 22:02:27 UTC
Today again Documents view is empty (is present only one new Untilted).
Seems creating new session and open here documents only confirmed that the problem with restore session persists.

I"m not sure why anybody cannot reproduce the issue. Maybe I didn't clicked proper options in settings?
Comment 27 Waqar Ahmed 2024-10-30 07:55:41 UTC
I dont think many people are trying and I am not an active user of sessions or plasma restore. I rarely shutdown my pc.

Can you reproduce the issue if you kill kate and start again?

it must be sigkill, Kate handles other signals and tries to shutdown gracefully.
Comment 28 Piotr Mierzwinski 2024-10-31 23:17:36 UTC
(In reply to Waqar Ahmed from comment #27)
> I dont think many people are trying and I am not an active user of sessions
> or plasma restore. I rarely shutdown my pc.
so instead do you put your computer to sleep?

> Can you reproduce the issue if you kill kate and start again?
> it must be sigkill, Kate handles other signals and tries to shutdown
> gracefully.

I killed kate by SIGKILL, and run it using Kicker. In result session was restored only I lost content of "Untilted" (appeared empty).
I did it twice with the same result. Also tried with default signal, so TERM and worked well. 
I don't know how plasmashell closes its children, maybe this is some specific way what is not supported by kate?
Comment 29 Piotr Mierzwinski 2024-11-03 01:07:05 UTC
Today (Saturday) surprise, so all have been restored correctly (including 2 "Untilted"). We will see tomorrow.
Comment 30 Piotr Mierzwinski 2024-11-06 16:08:14 UTC
(In reply to Piotr Mierzwinski from comment #29)
> Today (Saturday) surprise, so all have been restored correctly (including 2
> "Untilted"). We will see tomorrow.

Also it worked well at Sunday and Monday.
Unfortunately today I met empty Documents list (except one empty "Untilted") :(
The only difference was that I did nothing in Kate since last days.
I'm not sure if solution implemented in Kate is reliable.
Comment 31 Waqar Ahmed 2024-11-18 08:40:38 UTC
There are bugs still, yes.

It would help more if the bug report contains exact steps to reproduce the issue quickly. That way it is likely that it will get fixed soon. With a generic report "i have a problem that happens", things will take a while because someone needs to put in the effort and find how exactly the bug happens before fixing it. There are probably cases still left where session is not saved properly.