Martijn has Bear

Struggling to restore a Firefox window

Stuff happens. Actually, I am not sure what is to blame. I quit Firefox by right-clicking in the Windows task bar and selecting “Close all windows”. Today I started Firefox and it prompted me to allow it to do an update. Once it started for real (with the previous session) my main window was missing. Bye-bye tabs.

After a browser restart it no longer considers any windows to have recently closed. (So nothing in the History menu.) Nor did it think there was a failed session restore. (So nothing available on about:sessionrestore.)

It is hard to say what behaviour actually made me lose the window. (Or made Firefox think it was closed normally before the browser quit.) Could have been something with how Windows was closing the windows. Or something with how the browser update reloaded the session.

There are other behaviours I have had issues with when trying to get Firefox to restore my session. One of those has a 2 year old bug report: when an external application triggers Firefox to start, it will not always restore the session.

It is also nearly impossible to restore my tabs from the browser history. This is because tabs loaded during a session restore are not put into recent history. Many of the tabs I just lost might have been with me through several restarts, so they can be months old. Good luck finding that one page in just a few weeks of my heavy browsing, let along a few months.

After some more digging I found out about %APPDATA%\Mozilla\Firefox\Profiles\*\sessionstore-backups. This is a local folder that Firefox keeps some old data around in. Most of it are the current browser state, but there are a couple of files called “upgrade”. (I think these are from previous browser updates?) One of them was 2 weeks old. A bunch of my tabs would have been around 10 days ago as well, so lets check this one out!

The file uses a compressed JSON format called jsonlz4. Jefferson Scher has published a number of online tools for unarchiving Firefox formats, including the Session History Scrounger. (Source available on GitHub.) I dropped my file into it and had it write everything out as an “Unstructured URL list” onto the page.

I copied all that text into the input field of the Open Multiple URLs Firefox add-on, hit the “Extract URLs from text” button, toggled “Do not load tabs until selected”, and then let it open 473 tabs while I held my breath.

After a little bit of a hang, Tab Counter Plus is telling my I now have 474 tabs in the current window. The lazy loader build into Open Multiple URLs puts all the URLs right in the tab title. So now I get to close a bunch of them before even loading them. Still painful but not as painful. Let’s see how many tabs I actually end up keeping.

After looking around a bit for how to prevent this in the future, I read people are still recommending Tab Session Manager. An officially Recommended add-on. It boggles my mind that people feel the need to secure their browser sessions with a third-party tool. But I too am now looking into adding it to my add-on list.