Session Restore intermittently saves tabs:[] and loses all open tabs after a normal shutdown
Categories
(Firefox :: Session Restore, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: s.morgun.0333, Assigned: spohl, NeedInfo)
References
(Blocks 1 open bug, Regressed 1 open bug)
Details
(Keywords: dataloss, Whiteboard: [fidefe-session-restore])
Attachments
(1 external file, 1 obsolete file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:154.0) Gecko/20100101 Firefox/154.0
Steps to reproduce
This issue is intermittent and has occurred at least three times: around August 28, August 30, and October 8, 2026.
- Enable Settings > General > Open previous windows and tabs.
- Use one normal Firefox window containing fewer than 10 open tabs, including tab groups.
- Close Firefox normally.
- Shut down Windows normally.
- Start Windows again.
- Launch Firefox.
I cannot reproduce the issue on demand. Firefox may work normally for days or weeks before the session is lost again.
Actual results
Firefox opened with only one about:home tab. All previously open tabs and tab groups were missing.
History > Restore Previous Session was unavailable, and the missing session was not present under Recently Closed Windows or Recently Closed Tabs.
I backed up and decoded the session files before attempting recovery:
- previous.jsonlz4: windows=1, tabs=0, _closedTabs=25
- recovery.jsonlz4: windows=1, tabs=1, current URL=about:home, _closedTabs=25
- recentCrashes=0
The 25 closed entries were older tabs that I had manually closed. They were not the missing active session, which contained fewer than 10 tabs.
For the most recent incident:
- Windows shut down normally at 07:00:49.
- Windows started at 18:35:32.
- An empty Firefox session was written at 18:43:14.
- I did not manually launch Firefox at 18:43.
- I first manually launched Firefox at approximately 19:27 and found the empty session.
The session files were valid JSON and were not truncated or unreadable. Firefox had recorded closed tabs in _closedTabs but recorded no active tabs in tabs[].
There was no corresponding Firefox crash report, Windows application crash, or Firefox update at the time.
Replacing the empty files with an older valid sessionstore backup restored the tabs successfully. After Firefox worked normally for some time, the same data-loss problem occurred again.
Expected results
Firefox should restore all tabs and tab groups from the previous session.
If restoration fails, Firefox should retain the last valid session as a recoverable backup instead of overwriting it with a clean session containing tabs:[].
Comment 1•1 month ago
|
||
The Bugbug bot thinks this bug should belong to the 'Firefox::Session Restore' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•1 month ago
|
||
Thank you for the detailed report! We have seen a lot of bug reports like this, seemingly occurring very rarely. We are actively investigating what causes Firefox to seem to start up without its previous session data.
I think this is the first time we've seen a clue like this:
- An empty Firefox session was written at 18:43:14.
- I did not manually launch Firefox at 18:43.
- I first manually launched Firefox at approximately 19:27 and found the empty session.
Based on what you described, it sounds like you do not have Firefox configured to start up when Windows starts up. You said that there was no Firefox update pending at the time -- does that mean you did not have an available update at the time that you shut down Firefox around 07:00?
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 3•1 month ago
|
||
I've reproduced a sequence that produces the same session-file contents reported here: one window with tabs: [] and the old _closedTabs entries still present, followed by a startup with only about:home. This gives us a concrete data-loss mechanism to fix. I haven't established that it's the trigger for the reported incidents, or what started Firefox at 18:43. I thought it would be worth giving a detailed writeup of what I found.
Sergey, I added a need-info for you to answer the question at the end of the paragraph that starts with "There are two Firefox-written examples". This writeup ended up a bit longer than expected, but I'm hoping that the level of detail is helpful to evaluate the two patches that I intend to post shortly.
How the loss happens:
- A saved split view can describe two member tabs even though only one of those tabs survives serialization.
keepOnlyWorthSavingTabs, whichSessionSavercalls before every write, filters the tab list without updatingsplitViews[].numberOfTabsor the surviving tab'ssplitViewId. The file can therefore be valid, complete JSON while its tab and split-view metadata disagree. createTabsForSessionRestorecreates the tabs before inserting them into the tab strip. For a split view, it waits until it has collected the recorded number of members before creating and attaching the split container. If the file promises two members but supplies one, the remaining tab can stay detached. A later call to#restoreTabthen throws because that tab has no position.- Reusing the startup tab can hide this problem. With vertical tabs, or when the selected tab needs a different container, restoration creates a new tab instead. If every restored tab stays detached, removing the leftover startup tab can close the window before
#restoreTabseven runs. On Windows and Linux, closing the last window can also quit Firefox. Tab loss also reproduces on macOS, but the application doesn't quit through that same last-window path. - During that quit, the non-macOS session-saving path promotes the last closed window back into the session. Filtering removes its empty tab state while retaining the window and its old closed-tab entries. That would explain how Firefox can write
tabs: []alongside intact_closedTabs, without a crash or a truncated file. On the next startup, the first session write rotates the file that was read intoprevious.jsonlz4, while the new session containsabout:home. The emptyprevious.jsonlz4therefore points to an earlier run having already written the empty session.
There are two Firefox-written examples of the split metadata becoming inconsistent. Saving just after "Add Split View", before the new partner's history has been collected, can omit that partner. In the tested run, collection took about 15 seconds without a flush. A normal quit flushes first, so this reproduction depends on a save without a flush, such as a periodic recovery save. More significantly, a split containing a normal URL and a newly opened about:privatebrowsing tab in a normal window still loses the latter during the worth-saving filter after a full flush. The URL tab remains associated with a two-member split. This second example survives a normal quit, so the problem doesn't require a crash or an interrupted write. It's an unusual combination, and I'm treating it as evidence of the writer defect rather than assuming it matches the reporter's browsing. We don't have evidence that the reporter used split views, vertical tabs, or about:privatebrowsing. But of course, if you could confirm or deny this, Sergey, that would be very helpful.
I verified the resulting startup loss in a Linux VM with Firefox 154.0.1 and 158.0.1, and verified a normal quit/restart cycle using the same current Nightly build to produce and restore the file. With vertical tabs, that cycle quit on its own and subsequently opened about:home. A separate test with a hand-constructed session file, missing group definitions, and 25 old closed tabs reproduced the reported counts exactly. I haven't run the Windows reproduction. The Windows connection comes from tracing the shared last-window shutdown and session-saving paths. A short-lived startup like this could go unnoticed, but it doesn't establish how the 18:43 launch occurred.
How this relates to D332744:
Nikolai Dokutovich correctly identified another route to a detached tab: a groupId that isn't present in the window's groups list skips insertion. Restoring that tab ungrouped is useful, and moving the missing-position check before the busy-state increment is also sensible. The group-restore patch I'm preparing is inspired by D332744. As clarified in bug 2080608 comment 5, the earlier real-world missing-group example came from a session-rewriting tool. We still haven't identified a Firefox writer that produced that particular mismatch.
The part I don't think is sufficient is catching each #restoreTab exception and continuing. That may let later tabs restore, but it doesn't attach the failed tab or preserve its history. It also runs too late to prevent the all-detached window from closing during tab creation. In the Linux VM, D332744 alone still lost the incomplete-split tab with vertical tabs, and that run also lost all 14 old closed-tab entries. There's a separate caller problem with the ungrouped fallback: reopening a saved or closed group expects an actual group back. With inconsistent member IDs, it can restore a tab ungrouped, forget the saved/closed group entry, and then throw at group.select() because the returned group is null (see openSavedTabGroup and undoCloseTabGroup). I reproduced that failure for saved groups in the Linux VM and for both saved and closed groups in the local macOS browser tests. That's a group-reopening contract problem, even when the individual tab's history survives.
I'm planning to post two patches here soon:
- Reconcile split metadata with the tabs that remain, both before writing the session and before constructing restored tabs. Counts come from the actual members, and a lone survivor or a tab with no usable split definition restores as an ordinary tab. The save pass also covers closed windows, saved/closed groups, and the retained previous-session state. It doesn't bring back tabs that were intentionally filtered out.
- Keep the unknown-group fallback, using the existing ordinary-tab insertion path, and use the containing saved/closed group's ID when reopening its members. This should preserve the group that those callers expect. The patch retains the earlier position check without adding the broad per-tab catches.
The empty-window shell is retained because it can still contain recoverable closed tabs. These patches aim to prevent the tab loss that leads to that state, rather than deleting the remaining recovery data. Broader input validation remains tracked in bug 2083249.
Local verification on macOS passed 167 browser checks across six test files and 36 unit checks. Both new browser regression tests fail with the production fixes removed. The tests cover history and selection surviving a second restore, horizontal and vertical tabs, containers, incomplete splits, filtering before a disk write, and saved/closed-group reopening.
| Assignee | ||
Comment 4•1 month ago
|
||
Before, with only the two new browser regression tests and no production fixes: both tests failed on Linux and Windows 11. The incomplete split-view test timed out, and the unknown-group test failed tab order and selection checks before timing out.
https://treeherder.mozilla.org/jobs?repo=try&revision=8a374c746475e82af36131baea4785486f8049a3
After, with both patches: the sessionstore browser and xpcshell tests passed on Linux and Windows 11. All 20 jobs passed. Both pushes used the same source base. macOS was tested locally.
https://treeherder.mozilla.org/jobs?repo=try&revision=6e73f7fbc7df
| Assignee | ||
Comment 5•1 month ago
|
||
Inspired by Nikolai Dokutovich's proposed fix in https://phabricator.services.mozilla.com/D332744 for bug 2080608.
Updated•1 month ago
|
| Assignee | ||
Comment 6•1 month ago
|
||
Dropping a split partner in keepOnlyWorthSavingTabs can leave an incorrect member count. Restoring that state can leave the remaining tab detached. On Windows and Linux, if it was the window's only tab, the window can close and Firefox can quit, writing an empty window.
Comment 7•14 days ago
|
||
Redirect a needinfo that is pending on an inactive user to the triage owner.
:jswinarton, since the bug has high severity and recent activity, could you have a look please?
For more information, please visit BugBot documentation.
Updated•2 days ago
|
Comment 9•2 days ago
|
||
| bugherder | ||
Comment 10•2 days ago
|
||
Did you want to nominate this for the Fx163 relnotes? If so, set the relnote-firefox flag to "?"
https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination
Possible wording:
Fixed all open tabs sometimes being lost after restarting Firefox when using Split View.
Description
•