Open Bug 2087599 Opened 25 days ago Updated 1 day ago

A failure while preparing a deferred session drops the saved tab groups

Categories

(Firefox :: Session Restore, defect)

Firefox 161
defect

Tracking

()

ASSIGNED

People

(Reporter: ndokutovich, Assigned: ndokutovich)

References

Details

Attachments

(1 external file)

#initSession assigns the saved tab groups inside the try block that also prepares the session:

try {
  ...
  this.#savedGroups = state?.savedGroups ?? [];
} catch (ex) {
  decision.initError = ex.name;
  this.#log.error("The session file is invalid: ", ex);
}

Anything that makes the preparation throw leaves the saved tab groups empty, and the next state we write replaces sessionstore.jsonlz4, so the groups are gone for good.

The saved tab groups do not depend on the windows the state carries. Carry them over even when the rest of the state could not be processed.

Reproduction: a session file with browser.startup.page set to 1, three saved tab groups, and a window without _closedTabs. Before the patch the file written back during the session has savedGroups: []; after it, the three groups are still there.

Test: browser/components/sessionstore/test/marionette/test_saved_groups_survive_unusable_session.py

#initSession assigned them inside the try block that also prepares the
session, so any state that failed to prepare left the list empty. The next
state we write replaces sessionstore.jsonlz4, so the groups were gone for
good.

The saved tab groups do not depend on the windows the state carries.

Assignee: nobody → ndokutovich
Attachment #9671802 - Attachment description: WIP: Bug 2087599 - Keep the saved tab groups when the session cannot be prepared. → Bug 2087599 - Keep the saved tab groups when the session cannot be prepared.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Patch up for review: https://phabricator.services.mozilla.com/D338378

The test fails without the change (an empty list instead of the three saved groups) and passes with it.

A second trigger, which does not need a window missing _closedTabs: a tab whose groupId has no entry in window.groups makes #prepDataForDeferredRestore throw at groupStateToSave.id, which lands in the same catch. After startup SessionStore.savedGroups is [].

Same failure as bug 2088568. The test in D338378 now covers both triggers.

See Also: → 2088568
Duplicate of this bug: 2088568

Bug 2088568 has been marked a duplicate of this one. It is the same trigger, so the patch now covers it as well.

#prepDataForDeferredRestore used to abort when a tab's groupId did not resolve in its window. The tab's groupId is now dropped and the tab is prepared as an ungrouped one, so the loop continues.

The test uses two tabs: one whose groupId the window does not define, and one in a group it does define. After startup SessionStore.savedGroups holds the three from the session file plus the second tab's group, converted into a saved group. With the catch alone the loop stops at the first tab and that group is never converted, so the test fails with three ids instead of four; with both changes it passes. On an unpatched tree the same state throws in #prepDataForDeferredRestore and SessionStore.savedGroups is empty after startup.

The catch remains for other preparation failures, such as a window without _closedTabs, and no longer lets a state whose savedGroups is not a list stop startup.

See Also: → 2089794
See Also: → 2083249
See Also: 2088568 →
See Also: → 2063477
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: