Browser-laptop: Brave should restore session gracefully after a crash

Created on 9 Nov 2016  路  51Comments  路  Source: brave/browser-laptop

Did you search for similar issues before submitting this one?
Yes

Describe the issue you encountered:
Brave is not aware during re-launch that it had a crash during the last run. In some cases, it doesn't properly save the session file (leaving them with an empty session).

Expected behavior:

  • If the session file is corrupt (fails JSON.parse):

    • [x] Brave should backup the existing broken session file. (added with https://github.com/brave/browser-laptop/pull/7690)
    • [ ] Brave should try to search for a last known good session to restore. Usually, the session is named with a ".tmp" or similar extension before it gets renamed to the final "session-store-1".
  • If the session is not restorable, we should:

  • If the session is fine

    • [ ] Brave should save a "clean shutdown" flag of some sort when saving. Doing so would mean that this session file would need to be saved without that flag on startup, so that we can detect the condition.

In those cases, regardless of what the "start brave with" setting has, we should show an alert letting the user know:

  • Brave crashed and it was unexpected
  • We can try to restore the sites (windows and tabs) that were open, if they'd like us to
  • Steps to reproduce:

    1. Launch Brave and open some tabs, each to a different site
    2. On Windows, open up task manager. On Linux/Mac, use ps -ef | grep brave
    3. Kill the main Brave process (end task or w/ kill command)
  • Screenshot if needed:

  • Any related issues:

addressed-with-brave-core parity prioritP2 project-tracking

Most helpful comment

FYI if this happens to you, make sure you make a backup-copy of session-store-1 before you re-open Brave. If you forget to do this and re-open Brave, you still have about 5 minutes to backup session-store-1 before everything is lost.

Usually the deletion happens on startup, not shutdown.

All 51 comments

Manual work-around I've given to folks for trying to restore their session:


First, quit Brave and make sure all instances of it are closed (if you know how, you can check task manager to make sure no Brave.exe are running)

Then push Windows key + R to bring up run prompt and then run:
%appdata%brave

You should then see your local files. The session files have the format of "session-store-". Look for others with a similar name which are bigger in size. Backups are saved every so often, including when quitting. You should be able to rename the file you want to restore as "session-store-1"

Please let me know how this works for you. I would advise not to delete files... but if needed, rename them or put into a folder

bsclifton, I saw only 2 session files...one from today and a tmp file from Aug 30. I checked several folders...did not see other session files.

@ktd99 apologies- maybe I responded to your issue too quickly. Did you lose your data? (which this process helps recover) or did you only lose the open tabs for one session?

You can re-open previously closed tabs (see history menu, or press Ctrl+Shift+T)

I lost all but 5 tabs...quite a lot. And some had been open for months, so the History option is far too tedious....not even sure it would go back far enough.

@ktd99 I updated the original post above (here in this issue) to make sure when this is fixed that we restore tabs and windows that were open before the crash happened.

It doesn't help you now, but I am glad to hear that you have all your other data though :smile:

Experienced a similar variation of this issue about an hour ago.

I restarted my Win 10 64bit laptop after a system crash:

-Opened Brave
-My usage stats on the home screen and all my bookmarks are gone.
-Brave payments was disabled (when reactivated, all my info was correct and as expected),
-Extensions were disabled (reactivated and those are back to normal as expected).
-The main bummer is I liked how high the stats were, and my bookmarks are gone (and I didn't back them up).
-Behavior roughly matches a fresh install, minus the oauth, payments and extensions going back to normal after being enabled.

Brave Info:
Name: Version Brave: 0.12.15 Muon: 1.4.31 libchromiumcontent: 53.0.2785.143 V8: 5.3.332.47 Node.js: 6.5.0 Update Channel: dev os.platform: win32 os.release: 10.0.14393 os.arch: x64

I checked out this issue and issue #5852, but am only seeing one session-store file:
session-store-1 and no other session-store-tmp or other session-store variations.

Luckily I'm OCD and double down on bookmarking links into Pocket (very happy for that extension right now), but let me know if there's anything else I can provide to assist.

I second the people who have recently lost their bookmarks. I had these as recently as earlier today, but now do not have them. There were several hundred, so it's not something I would ever be able to recreate perfectly. I looked at the files, but there is only one session-store file, so the propsed manual workaround will not work.

In recent versions (0.13.5, OS X), I haven't been losing my bookmarks, but I have been losing my windows, when there's a Brave or OS X crash. Individual tabs are in the history, but "Reopen Last Closed Window" has no effect. For tabs that have been open for several days (e.g., gmail), it's quite tricky to fully restore.

FYI an additional case, matching the samw issue I observed above, was reported in Community today.

https://community.brave.com/t/lost-all-my-bookmarks-thanks-to-latest-update/1683/6

This just happened to me, again.
I lost nearly everything (incl a bunch of work I was getting ready to submit in diff tabs)
Stuff that's gone:

  • brave stats
  • all history
  • all bookmarks
  • all open sessions (tabs and windows)
  • site preferences
  • security preferences (in settings - back to default)

Stuff that's OK:

  • Once payments was enabled again, my sitelist, wallet and payment stats were restored.
  • Authentication creds (I'm still signed into google - once I enable extensions, my creds are remembered)
  • Brave is still my default browser in Windows10

Browser version:

  • Brave: 0.14.0
  • rev: 7dfeeb0
  • This is the 2nd time this has happened to me, on 2 separate Windows machines, between January and now.
  • This is the 2nd reported case of this happening to a Windows user this week.

Conditions:

  • 4 Brave windows were open, with no more than 7 tabs open in each window.
  • Brave had been running OK, but had been running all day, and I have been running some heavy testing today.
  • I had Chrome open for some separate testing, with several windows open.
  • I had Slack open
  • I had Sublime Text open.
  • I got a BSOD - forced reboot.
  • I opened Brave after, and found that everything was gone.

I have noticed that Brave has been using a lot of memory over the past couple weeks (fluctuates, but is noticeable).

I have hardware acceleration enabled in Brave settings, if that makes a difference. Not sure if it does or not.

From what was not lost, this appears to be a bug in our handling of session-store-1 update. @lukemulks what was in the .tmp file, how big was it?

@BrendanEich the temp file was ~300k, the session-store-1 file was at less than 100k (I had only opened the browser and explored settings after noticing the stat count and session wasn't restored once I rebooted).

After I noticed what happened, I closed Brave, made a new folder, put session-store-1 in it.
Made another new folder, put the session temp store in it, and then renamed it to session-store-1.
I placed the renamed temp file back in the original location, and rebooted the browser.

I noticed that didn't seem to change anything, so I reversed the process in case I was mixing up the instructions, and it yielded the same result.

I can dump both sessions here if that helps at all? I'm not sure if they both were wiped, but the tmp file seemed small for what it contained. It all looks like hot mess when I open up the file, but can drop both files here. There are some params at the top and bottom that make sense to me.

The tmp file was dated as last modified on 02.16.17

FYI if this happens to you, make sure you make a backup-copy of session-store-1 before you re-open Brave. If you forget to do this and re-open Brave, you still have about 5 minutes to backup session-store-1 before everything is lost.

Usually the deletion happens on startup, not shutdown.

Does sync work in case of that kind of accident?

@luixxiul only for bookmarks, site settings, and (optionally) history right now, assuming either you saved the code words or have another synced device you can copy them from.

This just happened to me again. :-(

Like the last report, this came from (yet another) BSOD from Windows 10

Brave: 0.14.0 
rev: 77c562c3e8d1159e698e47a827a709939d0000b3 
Muon: 2.56.9 
libchromiumcontent: 56.0.2924.87 
V8: 5.6.326.50 
Node.js: 7.4.0 
Update Channel: dev 
os.platform: win32 
os.release: 10.0.14393 
os.arch: x64

win10 BSOD error:
SYSTEM_SERVICE_EXCEPTION (nvhda64v.sys)
This BSOD is specifically caused by the NVIDIA HDMI driver.

The previous BSOD above was caused by a BAD_SOCKET_POOL error, which I've resolved and haven't had a repeat of since (dell phone-home nonsense)

  • This time, I didn't have a session-store-tmp... file, only session-store-1.
  • This time, I (of course...smh...) did not have a backup, because I can't for the life of me remember to backup my session-store file, and when I do remember, it's been too little, too late.

  • Lost: bookmarks, brave stats - similar to past reports.

  • Kept: authentication, Brave Payments was intact once enabled. Pocket works.

Conditions:

  • I had the computer in sleep mode. When I awoke the computer, I got the BSOD.

  • I had both the production and dev (master) builds running when the computer was put into sleep mode (prior to BSOD).

  • I've attached the session-store-1 file that was remaining after the issue was discovered (probably not helpful).

session-store-1-postbsod.txt

  • I've been doing some heavy debugging and automated testing today. Pushing the machine really hard.

  • I had hardware acceleration enabled in Brave.

  • I'm going to disable hardware acceleration, just in case, and see if this repeats the issue. (probably longshot - but down to try anything to see if it helps).

Wondering if there's potentially something with how windows 10 handles driver management (or hardware for that matter) that gets wiped that also applies to our session-store...I have no idea, but this seems to be happening on BSOD more frequently, and windows has decided it needs to 3p drivers - I ran into a ton of issues when i adopted win10 last years, just throwing that out there. I am going to see if I can find anything that appears linked in the windows world.

@bsclifton if you need anything lemme know.

fwiw - for the above comment - I also had chrome open at the time that this all went down.

when I opened chrome, I was prompted to restore the session that had crashed.

if we can do something similar, that would be awesome. I think we might have an issue for that already, but wanted to note since I didn't have chrome open the last time this happened.

I slightly started to believe that we need some kind of "stress" test, which includes killing the program etc.

Another sad report here: https://twitter.com/themooring/status/847874005965131776

during today's update I lost all of my open windows/tabs that I was actively using (40+). Does history not go back more than 7 days?

This is related with #5590 as well.

It happened on my win10 laptop as well. I had a system crash and after restart I saw nothing. I didn't have any tmp file, but I had backup file, I tried to replace original store-session-1 with the backup, but it didn't help.

@SergeyZhukovsky if the JSON was corrupted, the file name would have backup in it. I bet that didn't happen though.

Although the code I put in place does help, it doesn't fix the root cause. I believe the root cause for this issue was correctly identified by @bridiver and is documented here:
https://github.com/brave/browser-laptop/issues/7876

This is scheduled for 0.14.3

If it was a file you backed up yourself you can replace while the browser is closed only, because otherwise when you close it will save over what you had.

We have a new report of this from a Brave Community contributor. Details below.

Community post URL: https://community.brave.com/t/brave-deleted-all-my-settings-and-all-bookmarks/2228/4

Contributor about:brave profile:

Name    Version
Brave   0.14.1
rev 3de60d5
Muon    2.57.8
libchromiumcontent  57.0.2987.133
V8  5.7.492.71
Node.js 7.4.0
Update Channel  dev
os.platform win32
os.release  6.1.7601
os.arch x64

Cc: @bsclifton @bbondy @BrendanEich for visibility.

@lukemulks ugh- sucks to hear 鈽癸笍 Our next release (0.14.3), we do have at least one potential fix planned (flushing the stream when writing)

We had another Community contributor report that they experienced this issue today.

Community post: https://community.brave.com/t/bookmarks-wiped/2318

Been using Brave for about two weeks now, and suddenly, after system reboots, the browser completely resets to new. Nothing is saved.

I am on an older PC that's subject to unexpected reboots, but this wasn't an issue when I first loaded Brave. Fortunately I only have a handful of bookmarks, but it's still a pain to reinstate them. What's going on?

Waiting for the about:brave profile. Will update this comment with the info when received.

We've had another Community contributor report:
https://community.brave.com/t/all-bookmarks-deleted/2682

Profile:

Surface Pro 3 running Windows 10 Pro 64 bit (10,0 build 14393)

Brave: 0.15.1 
rev: ea5024d1f3e47d34de79b70e3cd74f1408c985ce 
Muon: 2.58.8 
libchromiumcontent: 58.0.3029.81 
V8: 5.8.283.32 
Node.js: 7.9.0 
Update Channel: dev 
os.platform: win32 
os.release: 10.0.14393 
os.arch: x64

Feedback:

_Windows 10 gave me a blue screen of death. Upon opening Brave asked me to make it default browser, had dropped all tracking stats to 0 and lost all of my book marks (hundreds, saved only in brave, not in other browsers. ENORMOUSLY disappointing.) This is how we lose users to another browser._

_Tried renaming session store backup to session store 1 multiple times which did not fix issue._

One additional follow-up:

_One addition: went to settings and set password manager back to Lastpass, which still remembered me. Did not even require inputting master password._

The follow up above aligns with what other users have experienced (creds sticking, and extensions retaining original settings, only issues with the session-store)

temporary workaround is to sync the history and bookmarks and save the passcode. After BSOD they should be recovered if Sync has worked without issue.

Thanks for the reminder @luixxiul - I'll let the user know in this case.

The workaround will be helpful for many users, but I suspect that there are a good amount of users that only use one computer. Definitely good for users that have Sync capability. :-)

It happened again today on my win10 laptop with the latest stable Brave 0.15.2. I had a File History feature enabled and I restored it from previous backup, I just replaced session-store-1 file.

Still happening on a near-daily basis. After a crash with multiple windows and tabs open, Brave opens with a blank window. MacOS 10.12.5, Brave 0.15.314 . My only other devices are Android, so the Sync workaround doesn't help.

+1 from https://community.brave.com/t/crash-then-all-windows-from-last-session-are-gone/3730/2

I know from experience that when a crash happens, you don't always lose your session. Many times, you only lose your window state (ex: the tabs you had opened, etc). This is a bad experience

+1 from https://community.brave.com/t/crash-then-all-windows-from-last-session-are-gone/3730/7

We should do a better job storing the window state (and trying to recover it)

+1 from Twitter https://twitter.com/LewisWade35/status/880908370454220800

Win 7, updated to 0.17.3 and lost bookmarks.

@LaurenWags just bookmarks? We need to separate complete loss of state from partial loss of state and also differentiate between pre and post file io sync versions. @bbondy what was the first version with the code that fixed the atomic writing of the state? Complete loss of state is one issue, loss of individual windows is another issue (should also be fixed in a recent version) and loss of parts of app state (bookmarks for instance) is yet another issue. Combining them into a single issue confuses the causes and makes tracking more difficult.

I can confirm that the same issue happened to me just now. IIRC about 15 minutes ago a tab wasn't loading, with an error on the tab. I thought I'd wait for it to clear up and use another browser in the meantime. When I went back to Brave just a few minutes ago, the browser page was still greyed out, so I closed it. When I opened it again, all my tabs were gone, despite my settings being set to open where I left off. I'm using Brave 0.17.13. Windows 10 Pro v. 1703.

+1 from @Miyurz in #9885.

I opened my notebook today at work and all Brave windows are white. I can't reload or do anything. I closed the App and started again. One window opened i closed yesterday, but the window that was still open are lost. This is kind of a critical feature to me, so i have a session save extension in Chromium. There i also lost my tabs 2-3 times... (i have sometimes 200-300 tabs but here it was less than 30!)

Brave: 0.18.36
rev: 7ab85e97318fef041433b0c3d73b457205fae805
Muon: 4.3.22
libchromiumcontent: 61.0.3163.79
V8: 6.1.534.32
Node.js: 7.9.0
Update Channel: dev
OS Platform: Linux
OS Release: 4.10.0-33-generic
OS Architecture: x64

+1

Chrome won't restore my session any more, which is really annoying because I want to continue with the tabs.
I only had a single session file that looks like it has perfect and consistent JSON structure.
All I need from it are the urls, I'm happy to copy-paste them into Chrome.
But I cannot find them in the file, can you explain the restore file structure and where I can find the urls that where open?
I don't need the history or anything else in the tabs.

Sorry for any noise, but it's unclear after reading through this and several other issues whether or not I should be surprised to learn that after I forgot and left my laptop on battery only, the machine shut down and now after rebooting my bookmarks seem to be 100% completely gone away forever. The browser opened with all tabs where they were, and passwords were all still there. So I was decoyed by that, and didn't notice until later (longer than 5 minutes) that my bookmarks had disappeared.

Is there any hope? Linux Slackware 14-current, 0.22.810. I back up weekly, but naturally these past few days were filled with intense work because of an upcoming conference presentation.

in general, in such cases, you can run a restored backup, export just the bookmarks, and import them in the live system. maybe they are in one file you can just restore from backup.

can't tell specific for this browser since i don't use it anymore because of such issues.

Am 27. Juni 2018 08:42:04 MESZ schrieb Brian Capouch notifications@github.com:

Sorry for any noise, but it's unclear after reading through this and
several other issues whether or not I should be surprised to learn that
after I forgot and left my laptop on battery only, the machine shut
down and now after rebooting my bookmarks seem to be 100% completely
gone away forever. The browser opened with all tabs where they were,
and passwords were all still there. So I was decoyed by that, and
didn't notice until later (longer than 5 minutes) that my bookmarks had
disappeared.

Is there any hope? Linux Slackware 14-current, 0.22.810. I back up
weekly, but naturally these past few days were filled with intense work
because of an upcoming conference presentation.

--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/brave/browser-laptop/issues/5512#issuecomment-400560378

--
Diese Nachricht wurde von meinem Android-Ger盲t mit K-9 Mail gesendet.

I think we made some good progress with browser-laptop, but I don't think we'll be able to address the remaining issues

This experience for sure will be better with brave-core (new version of our product forked from Chromium). For folks that ran into issues with Brave who wanted to give it a second try, you can try the new version (currently on our Developer channel) available here:
https://brave.com/download-dev

I just switched to the brave-core version. Will distribution be done someday with a similar (e.g. Brave.tar.bz2) version loadable from the Releases github page, as was done with browser-laptop? Or is there a "transition document" out there that needs to be perused?

@capouch The brave-core releases are available here: https://github.com/brave/brave-browser/releases

@capouch in addition to the releases page that @Liunkae mentioned, we also have a Linux setup document for package manager integration:
https://brave-browser.readthedocs.io/en/latest/installing-brave.html#linux

Has something changed for newer release packs? wget 403s. . .

`wget https://brave-browser-apt-dev.s3.brave.com/pool/main/b/brave-browser-dev/brave-browser-dev_0.55.10_amd64.deb

--2018-09-27 03:14:41-- https://brave-browser-apt-dev.s3.brave.com/pool/main/b/brave-browser-dev/brave-browser-dev_0.55.10_amd64.deb

Resolving brave-browser-apt-dev.s3.brave.com... 151.101.194.217, 151.101.130.217, 151.101.66.217, ...

Connecting to brave-browser-apt-dev.s3.brave.com|151.101.194.217|:443... connected.

HTTP request sent, awaiting response... 403 Forbidden

2018-09-27 03:14:42 ERROR 403: Forbidden.`

@capouch I think you've gotten sorted right? (I saw you commenting in brave-browser repo). Just wanted to check 馃槃

@bsclifton Yes, thank you. Now there are .debs right there with the release announcement, at least (as of early this morning) for the 55 series, but not yet for 0.56.x

AFAIC this is not due to any sort of 'corruption', perhaps not even an update (though evidentally the management / backup of the session-state is for discussion), but the sum of content in the 'session-state-1' file.

File itself is 1004K in size, UTF-8, parseable (less, cat, grep) and contains no malformed characters (9545).

If I enter an end-of-line (\n) before each URL in the file and output to a new file, I am able to manipulate and read the file with any editor (Atom, gedit) without issue.

Without removing any cached data, removing 'session-state-1' restores Brave's functionality and I have maintained sessions... though I have lost all bookmarks and ad, tracker block and upgrade metrics (far more frustrating than it should be).

For what it's worth, I first noticed issues when arranging bookmarks into folders; objects would disappear or re-appear in the original folder. It looks to correlate with updating the session-state file itself, but I've not looked into the mechanics of the write-backs yet. My research suggests this issue manifests after a varying period of time, which marries my thinking.

Given that the construct of the file (JSON) appears sound, I am able to extract important URLs and bookmarks... so that's something. I intend to play with stripping N 'records' from the file as I believe I should be able to coax it back into operation.

--##--

$ file session-store-1
session-store-1: UTF-8 Unicode text, with very long lines, with no line terminators

$ wc session-store-1
      0    9545 1027284 session-store-1

$ cat session-store-1 | sed 's/http/\nhttp/g' | wc -l
5052

$ cat session-store-1 | sed 's/http/\nhttp/g' > session-store-2

$ wc session-store-2
   5052   14586 1032336 session-store-2

Preliminary skimming of extracted bookmarks from the 'session-state-1' file suggests that there are duplicates (which were invisible in browser) that correlate with my re-arranging (i.e. folders and URLs exist in both source and destination).

Perhaps the trigger for this is not the content-length of 'session-state-1', but something related to the bookmarks themselves and the way they are parsed at start-up?

Something wasn't happy here, too;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukemulks picture lukemulks  路  3Comments

luixxiul picture luixxiul  路  3Comments

briannyeko picture briannyeko  路  3Comments

jkup picture jkup  路  3Comments

eljuno picture eljuno  路  3Comments