Firefox 56.0 - What is the new sessionstore file format?
I had a problem recently. FF 56.0 crashed, and when I went to restart it, the "restore session" window got hidden, so FF started with my single home-page window/tab. When I went to the sessionstore-backups directory, I saw
recovery,baklz4 recovery.jsonlz4
I renamed these files, as they were small and obviously contained only the one window and tab. Then I restarted FF, and again it started with only one window and tab. What I had to do was 1) terminate FF, 2) erase the two new recovery files, 3) uninstall FF, and 4) re-install the previous FF 55.0.3. Then FF was able to start and recover my previous FF window/tab configuration. I want to re-upgrade to FF 56./0, but I cannot do this until I understand the new recovery file format and know why FF 56.0 did not restart and use an existing recovery.js, recovery.bak, or previous.js file. I assume that the new file format has an "LZ4" zip compression of the files. Thanks.
--Barry Finkel
Solución elegida
I did upgrade to 56.0 this morning. I did see a sessionstore.jsonlz4 file in the parent directory, which I renamed before the upgrade. I must have missed this file before.
Please keep this open for a few days; then I will mark it as resolved. Thanks.
--Barry Finkel
Leer esta respuesta en su contexto 👍 0Todas las respuestas (13)
A lot of files in the profile folder are now packed with LZ4 (jsonlz4) to speed up reading and writing these files at startup and this includes sessionstore.jsonlz4 and files in the sessionstore-backups folder. Firefox can still restore an uncompressed sessionstore.js file as a fallback, but that requires to rename/remove present compressed .jsonlz4 files. In some cases it might work to place a sessionstore.js file (renamed recovery.js/bak) in the main profile folder, but you may have to rename the sessionstore-backups folder if that isn't working.
Here is what just happened.
55..0.3 I got a message last night about the update, so I downloaded it. This morning FF was running slowly, so I did an Exit. When firefox.exe was no longer running, I started FF in safe mode. Then FF decided to install the update. When FF started, there were only TWO tabs in ONE windiw - restore session and "what's new in 56.0". The restore serssion tab had a restore of ONLY ONE TAB - my home page. My previous sesssion, 15 windows with multiple tabs was NOT GIVEN AS AN OPTION. I then clicked the X in the upper right corner to cancel Firefox.
Here are the contents of the edfault (sdr) and sessionstore-backups (sr) directory:
sdr: 10/16/2017 08:42 AM 3,288,652 sessionstore.js sd: 10/09/2017 08:34 AM 3,302,926 previous.js
10/15/2017 09:29 PM 3,468,503 recovery.bak 10/15/2017 09:30 PM 3,468,541 recovery.js 10/16/2017 08:47 AM 1,557 recovery.baklz4 10/16/2017 08:48 AM 1,908 recovery.jsonlz4
As you can see, there is a sessionstore.js file from 55.0.3 when I did the clean Exit. Why is this file not seen and used by 56.0? This makes 56.0 unusable for me.
What I will do now is uninstall 56.0 and re-install 55.0;.3.
--Barry Finkel
After I wrote the info above, I realized that there is a piece of the puzzle - something changed in 56.0. In 55.0 there are in the sessionstore-backups directory:
recovery.bak recovery.js previous.js
and in the parent directlory
sessionstore.js
With 56.0, in the sessionsorw-backups:
previous.jsonlz4 recovery.jsonlz4
But I do not know where is the recovery file that 56.0 uses when it restarts. I think that the problem I described in my previous posting is this -- There was an existing file from the last time I installed 56.0; I did not delete it because I had/have no idea where that file is stored and its filename. There is no *.*lz4 file stored in the parent directory.
--Barry Finkel
Firefox 56+ versions use compressed .jsonlz4 files to store session date.
You may have to rename the sessionstore-backups folder and a possible sessionstore.jsonlz4 file in the main profile folder to make Firefox use the sessionstore.js file.
I will have to run a test sometime to see if 56.0 does store a sessionstore.jsonlz4 file when it terminates. I n the parent directory currently there is NO sessionstore.json;z4 file, and I know that I did not rename nor erase any ;z4 files in that directory. If I had seen one, I would have renamed or erased it. When I was running 56.0, I believe that I never did a clean Exit for Firefox to write the restore file in the parent directory. The first time I ran 56.0, it crashed when I was not at the computer. When I started Ff via the crash-report window, FF started in regular mode. When I went to start it in safe mode, I lost all my windows and tabs, so I had to re-install 55.0.3 to be able to read thee existing session-backups recovery file. And I did not re-upgrade to 56.0 until last night and this morning.
Another question - I have written scripts to read and format a .js file. Is there a utility to uncompress a jsonlz4 file into a js file? Thanks.
--Barry Finkel
See:
var {classes:Cc,interfaces:Ci,utils:Cu} = Components; function decompressFile(oFilePath,nFilePath){ Cu.import("resource://gre/modules/Task.jsm"); Cu.import("resource://gre/modules/osfile.jsm"); return Task.spawn(function* () { var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"}); yield OS.File.writeAtomic(nFilePath, jsonString);}) } // Set up file chooser var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen); fp.appendFilter("Bookmarks/Session (.jsonlz4)","*.jsonlz4"); fp.appendFilter("Search Engines (.mozlz4)","*.mozlz4"); fp.appendFilter("Add-ons Files (.lz4)","*.lz4"); fp.displayDirectory = fu.File(OS.Path.join(OS.Constants.Path.profileDir, "sessionstore-backups")); // Call file chooser fp.open((aResult) => { if (aResult == Ci.nsIFilePicker.returnOK) { if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) { var oldfile = fp.file.path; var newfile = oldfile + ".json"; // Construct output file name try { decompressFile(oldfile, newfile); console.log("Saved as: \"" + newfile + "\""); if(confirm("Open JSON file in a Firefox tab?")){ var uri="file:///"+newfile.replace(/\\/g, "/"); window.open(uri, "_blank"); } } catch (err) { console.log(err); } } } });
Modificadas por cor-el el
Backups are recommend during this trying (stuff) time.
Normally, after you exit Firefox 56, sesionstore.jsonlz4 is created in the main level of the profile folder.
If that file is missing at startup, you would expect Firefox to check in sessionstore-backups for recovery.jsonlz4 or recovery.baklz4. When Firefox looks for other files is a bit fuzzy in my mind.
There is some method Firefox uses to migrate Firefox 55 session history (uncompressed) to Firefox 56 (compressed), but I don't know what it is. If you were to hide everything except sessionstore.js, I would expect Firefox 56 to discover it at startup and convert it. Of course, I could be very wrong about that.
What kind of code are you using to parse the older JSON files? If it's JavaScript, you can add a library to decompress the new format. That's what I'm doing in this page: https://www.jeffersonscher.com/res/scrounger.html
The code I am using to reformat a .js file is an awk script. The .js file has everything "run-together" with no line splits. My code knows what each line in the file should contain, so I know where to put line breaks. I know that everything in the file is a separator that begins with one of these:
{"tabs": {"entries": {"url":
I do not know javascript. I wrote my first program in 1966 (FORTRAN II), and I have not learned much of the new languages.
I do not have a test system, so any testing I do would be on my real system. I believe, but want to test sometime (or look at the source code for 56.0), that if there is no lz4 restore file in the parent directory, FF 56.0 does not look in the sessionstore-backups directory for a .js restore file. I do not know if you have a test system on which to try this test.
--Barry Finkel
What I could do to test is create a new profile, close Firefox, delete all session history files, copy in the old sessionstore.js file from my regular profile, and then start Firefox again. But at the moment I'm not ready to exit Firefox...
Note that JavaScript has a JSON.stringify() function to format a file for readability.
JavaScript bookmarklet:
javascript:{try{js=JSON.parse(document.body.textContent)}catch(e){js=JSON.parse("["+document.body.textContent+"]")}try{if(js.length==undefined){js=[js]}document.body.innerHTML='<pre>'+JSON.stringify(js,null,1)+'</pre>'}catch(e){alert(e)}}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
jscher2000 said
What I could do to test is create a new profile, close Firefox, delete all session history files, copy in the old sessionstore.js file from my regular profile, and then start Firefox again. But at the moment I'm not ready to exit Firefox...
This did work:
With Firefox closed
(1) Rename sessionstore-backups folder to HIDEsessionstore-backups (2) Rename sessionstore.jsonlz4 file to HIDEsessionstore.jsonlz4 (3) Copy the old (pre-Fx56) session history file to the main level of the profile folder and rename it to sessionstore.js
After starting, using History > Restore Previous Session restored the copied-in session.
Solución elegida
I did upgrade to 56.0 this morning. I did see a sessionstore.jsonlz4 file in the parent directory, which I renamed before the upgrade. I must have missed this file before.
Please keep this open for a few days; then I will mark it as resolved. Thanks.
--Barry Finkel
We can close this thread. Thanks for your assistance,.
--Barry Finkel