A saved group entry that is not an object stops the browser from restoring a window
Categories
(Firefox :: Session Restore, defect)
Tracking
()
People
(Reporter: ndokutovich, Assigned: ndokutovich)
References
Details
Attachments
(1 external file)
Restoring a window reads the id of every saved group:
const openTabGroupIdsInWindow = new Set(
tabbrowser.tabGroups.map(group => group.id)
);
this.#savedGroups = this.#savedGroups.filter(
savedTabGroup => !openTabGroupIdsInWindow.has(savedTabGroup.id)
);
That code runs outside the try block in #initSession, so a savedGroups array carrying an entry that is not an object throws there. The exception escapes the window restore, the window never appears, and the browser sits in startup with no window at all.
With a resumed session (browser.startup.page set to 3) the deferred preparation does not run, so nothing filters the list before it reaches this point.
Filter the list once, after the session state has been read.
Reproduction: a session file with a resumed session and savedGroups carrying three groups and a null. Before the patch the window is never restored, and a Marionette client never completes a new session; after it the window is restored and the null is dropped.
Test: browser/components/sessionstore/test/marionette/test_saved_groups_invalid_entry_restore.py
| Assignee | ||
Comment 1•26 days ago
|
||
Restoring a window reads the id of every saved group, and does so outside the
try block in #initSession, so a session file carrying an entry that is not a
group object threw there. The exception escaped the window restore, the window
never appeared, and startup never completed.
Filter the list once, after the session state has been read.
Updated•26 days ago
|
| Assignee | ||
Comment 2•26 days ago
|
||
Patch up for review: https://phabricator.services.mozilla.com/D338379
It builds on D338378, since both changes touch the same lines in #initSession.
Comment 3•23 days ago
|
||
Hi Nikolai, thanks for the bug and the patch.
I agree that the patch fixes the problem, but we can't find a reliable way to get the session file into such a state, beyond creating one by hand. Do you know of a reliable way that this can be repro'd through the natural operation of the browser? Can you please post that? If not, we are inclined to not accept this — we try not to defend against situations that don't exist, as it increases complexity for no benefit.
| Assignee | ||
Comment 4•23 days ago
|
||
No, I don't have one.
Where these came from: I was adding marionette coverage for D338055 - the startup path, which a mochitest can't reach - and hit both while doing it. Neither has a producer inside the browser; I checked #recordSavedTabGroupState and the window-state builder before filing.
The one thing worth weighing is the failure mode: a single bad element in savedGroups means no window and a startup that never completes, not a broken feature. Seven lines against that.
The same is true of 2087599 - the trigger is synthetic there too. If we don't defend against states nothing produces, say so and I'll close both bugs and abandon the revisions.
| Assignee | ||
Comment 5•22 days ago
|
||
Correction to my comment above, last paragraph only.
I was wrong about 2087599. Bug 2088568, filed today, gives it a trigger I had not tested: a tab whose groupId has no entry in window.groups. I reproduced it on a clean tree - #prepDataForDeferredRestore throws at groupStateToSave.id, and the saved groups are [] after startup. So 2087599 is not synthetic-only; 2087600 still is.
My offer therefore applies to 2087600 alone.
| Assignee | ||
Comment 6•21 days ago
|
||
Correcting my correction: both bugs rest on constructed session files. Bug 2088568 described the same code path from inspection, not from an observed session, and I found no in-browser writer that produces a dangling groupId; the state can only arrive from outside the writer, since the schema does not relate a tab's groupId to its window's groups.
My offer therefore applies to 2087600 alone, unchanged.
| Assignee | ||
Comment 7•7 days ago
|
||
Clearing the needinfo - I answered above. Since then, bug 2092154 (telemetry for broken tab group references) explicitly counts a savedGroups entry that is not a group object, so we'll have a baseline for this case. Happy to keep the patch parked until that data lands.
Comment 8•2 days ago
|
||
The following patch is waiting for review from an inactive reviewer:
| ID | Title | Author | Reviewer Status |
|---|---|---|---|
| D338379 | Bug 2087600 - Drop saved group entries that are not group objects. | ndokutovich | jswinarton: Back Dec 7, 2026 |
:ndokutovich, could you please find another reviewer?
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 9•2 days ago
|
||
Holding this until the telemetry from bug 2092154 (D342632) produces a baseline; will revisit then.
Description
•