New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't delete saved session on crash #4672
Comments
Do you have auto_save.session set to true? Anyway, I'd like to keep a number of sessions as a backup. |
Leon George writes:
For debugging, i added a bit more output to qutebrowser.
The restart failed because i had forgotten to change my editor from tabs to spaces.
`TabError: inconsistent use of tabs and spaces in indentationTabError: inconsistent use of tabs and spaces in indentation`
After fixing that, qutebrowser loaded an empty session.
Oops. 60 tabs gone.
Only the new tab in `~/.local/share/qutebrowser/sessions`.
I don't think that should be expected to happen.
If it does, can qutebrowser make a backup of the old session file before overwriting it?
Reproducible.
I cannot reproduce, the _autosave session gets loaded correctly after a crash,
both with/without auto_save.session for me.
|
Can you say where the |
@toofar i edited qutebrowser/browser/webengine/webenginetab.py to debug whether skype was actually requesting permissions or just pre-emptively complaining. @arza-zara i use the default qutebrowser from arch-linux. no other files modified. this is my whole config:
|
here's a script to reproduce:
|
I can't reproduce this even with the script. The saved |
I can reproduce with this in source directory:
Crash reporter shows Open Pages as empty. Selecting |
@The-Compiler would you be interested in debugging remotely? @arza-zara if you close the dialog using ctrl-c in the terminal instead of using the buttons, does it restore the session? |
If I close the crash dialog with ctrl+c in terminal (or unchecking |
arza writes:
I can reproduce with this in source directory:
```
qutebrowser="./.venv/bin/python3 -m qutebrowser --debug -B $HOME/qutedir/"
file=./qutebrowser/browser/webengine/webenginetab.py
$qutebrowser -R ./tests/end2end/data/numbers/{1,2,3}.txt &
sleep 2
$qutebrowser :wq
echo GARBAGE >> $file
$qutebrowser
sed -i '/GARBAGE/d' $file
```
Crash reporter shows Open Pages as empty. Selecting `[x] Restore open pages` and `Don't report` opens only `url.start_pages`. `:session-load default` reloads the saved session.
I can reproduce with this method. The session is not loaded, but not
overwritten either, and loading the 'default' session will restore the saved
page.
I think the reason why the crash restore didn't work is because the _autosave
session (which is used for crash recovery ?) was not saved as the crash is too
early for that to happen.
FWIW, I would really like some style of log rotation on the autosave session
files, so even if things got overwritten, I would have <x> saves to notice
(not much help right now, but would help a lot after
#4545 with a high timeout).
|
i'm not sure any of your problems have much to do with mine (my session file isn't preserved and restarting qutebrowser a second time doesn't change anything either). what i find unintuitive about the behaviour on my computer is: i see now that the 'recovery' can't be implemented by 'not overwriting' the session. i'm glad you're all here looking at historical session files and different settings - but i don't see those issues as being related to mine. when i start qutebrowser with a session in the file system, encounter a crash, and terminate the process, i don't expect the session to be altered in any way. |
i'm not sure any of your problems have much to do with mine (my session file isn't preserved and restarting qutebrowser a second time doesn't change anything either). what i find unintuitive about the behaviour on my computer is: historical session files are separate issue, imho |
i've added log to find out when exactly the session file is altered:
the session file isn't altered until the instance that was started after the crash window is closed again. |
From @toofar in IRC:
|
Sessions are also deleted if you turn off qutebrowser normally, but immediately windows:
- active: true
geometry: !!binary |
AdnQywADAAAAAAAAAAAAFQAAB38AAAQ3AAAAAAAAABUAAAd/AAAENwAAAAAAAAAAB4AAAAAAAAAA
FQAAB38AAAQ3
tabs:
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: []
- history: [] All tabs is blank 😕 |
I don’t know, there are too many similar problems here, it’s very similar in description. |
I don't see how #3918 would be related at all. |
Adding some more details for an example of this issue that relates to the autosave session and an early crash:
There are a number of things I think we can do to mitigate this:
Here is a commit that does (3). We don't seem to have tests in this area (Edit: looks like this patch on its own creates an empty windows from the aborted load attempt which needs to be cleaned up):commit c3396ab3ccb8198041a82634392d700c096950b7
Author: toofar <toofar@spalge.com>
Date: Wed Dec 27 11:48:19 2023 +1300
Fall back to loading default session if autosave fails
If loading the autosave session fails you can be left with a browser window
with just your start pages in it, instead of the default session that is
normally loaded on startup (assuming you have `auto_save.session = true`). It
is then quite easy to overwrite your default session if you aren't careful.
This is particularly helpful when an early crash caused an invalid autosave
session to be saved, which we later fail to load. See https://github.com/qutebrowser/qutebrowser/issues/4672#issuecomment-1869807246
If the default session then fails to load the user will be back in the current
state of having a single browser window with their start pages open.
After this there will be a `_autosave.yml.bak` file saved to disk. Although
there is nothing to make that obvious to the user.
diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py
index c8445e4ad4d4..162398ccf80d 100644
--- a/qutebrowser/misc/sessions.py
+++ b/qutebrowser/misc/sessions.py
@@ -723,12 +723,17 @@ def load_default(name):
Args:
name: The name of the session to load, or None to read state file.
"""
- if name is None and session_manager.exists('_autosave'):
- name = '_autosave'
- elif name is None:
- try:
- name = configfiles.state['general']['session']
- except KeyError:
+ try:
+ last_session = configfiles.state['general']['session']
+ except KeyError:
+ last_session = None
+
+ if name is None:
+ if session_manager.exists('_autosave'):
+ name = '_autosave'
+ elif last_session is not None:
+ name = last_session
+ else:
# No session given as argument and none in the session file ->
# start without loading a session
return
@@ -739,6 +744,19 @@ def load_default(name):
message.error("Session {} not found!".format(name))
except SessionError as e:
message.error("Failed to load session {}: {}".format(name, e))
+
+ if name == "_autosave":
+ message.error(
+ "Attempting to save backup of autosave and trying main session"
+ )
+ path = session_manager._get_session_path("_autosave")
+ try:
+ shutil.copyfile(path, path + '.bak')
+ except OSError as err:
+ message.error(f"backing up autosave failed: {err}")
+ pass
+ session_manager.delete_autosave()
+ return load_default(None)
try:
del configfiles.state['general']['session']
except KeyError:
|
If loading the autosave session fails you can be left with a browser window with just your start pages in it, instead of the default session that is normally loaded on startup (assuming you have `auto_save.session = true`). It is then quite easy to overwrite your default session if you aren't careful. This is particularly helpful when an early crash caused an invalid autosave session to be saved, which we later fail to load. See qutebrowser#4672 (comment) If the default session then fails to load the user will be back in the current state of having a single browser window with their start pages open. After this there will be a `_autosave.yml.bak` file saved to disk. Although there is nothing to make that obvious to the user.
If loading the autosave session fails you can be left with a browser window with just your start pages in it, instead of the default session that is normally loaded on startup (assuming you have `auto_save.session = true`). It is then quite easy to overwrite your default session if you aren't careful. This is particularly helpful when an early crash caused an invalid autosave session to be saved, which we later fail to load. See qutebrowser#4672 (comment) If the default session then fails to load the user will be back in the current state of having a single browser window with their start pages open. After this there will be a `_autosave.yml.bak` file saved to disk. Although there is nothing to make that obvious to the user.
If loading the autosave session fails you can be left with a browser window with just your start pages in it, instead of the default session that is normally loaded on startup (assuming you have `auto_save.session = true`). It is then quite easy to overwrite your default session if you aren't careful. This is particularly helpful when an early crash caused an invalid autosave session to be saved, which we later fail to load. See qutebrowser#4672 (comment) If the default session then fails to load the user will be back in the current state of having a single browser window with their start pages open. After this there will be a `_autosave.yml.bak` file saved to disk. Although there is nothing to make that obvious to the user.
If loading the autosave session fails you can be left with a browser window with just your start pages in it, instead of the default session that is normally loaded on startup (assuming you have `auto_save.session = true`). It is then quite easy to overwrite your default session if you aren't careful. This is particularly helpful when an early crash caused an invalid autosave session to be saved, which we later fail to load. See qutebrowser#4672 (comment) If the default session then fails to load the user will be back in the current state of having a single browser window with their start pages open. After this there will be a `_autosave.yml.bak` file saved to disk. Although there is nothing to make that obvious to the user.
For debugging, i added a bit more output to qutebrowser.
The restart failed because i had forgotten to change my editor from tabs to spaces.
TabError: inconsistent use of tabs and spaces in indentationTabError: inconsistent use of tabs and spaces in indentation
After fixing that, qutebrowser loaded an empty session.
Oops. 60 tabs gone.
Only the new tab in
~/.local/share/qutebrowser/sessions
.I don't think that should be expected to happen.
If it is, can qutebrowser make a backup of the old session file before overwriting it?
Reproducible.
The text was updated successfully, but these errors were encountered: