Open Bug 1825868 Opened 1 year ago Updated 4 months ago

Accessing SessionStartup.sessionType getter too early will result in failure to restore a session

Categories

(Firefox :: Session Restore, defect, P2)

Desktop
All
defect

Tracking

()

People

(Reporter: mconley, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: dataloss, Whiteboard: [fidefe-session-restore])

I ran into this while debugging a patch for bug 1824094.

SessionStartup loads early on in the lifetime of the browser, and one of the things it does after initializing is to do an off-main-thread read of the SessionFile in order to see if there's anything there to restore: https://searchfox.org/mozilla-central/rev/6e4dc22cb30c9ffbfee917268c42b17ab8534b91/browser/components/sessionstore/SessionStartup.sys.mjs#134-137

However, between that initialization and the time that the file is read in and handled, callers can still attempt to access the SessionStartup.sessionType synchronous getter.

The problem here is that if we're still in the midst of loading the file, this getter will return NO_SESSION, and then cache the value, so that even if there was a session, SessionStartup will claim one doesn't exist. That sounds like a great way of losing a session.

We should probably make sessionType something that returns a Promise, and update all of the callsites.

OS: Unspecified → All
Hardware: Unspecified → Desktop

(In reply to Mike Conley (:mconley) (:⚙️) from comment #0)

We should probably make sessionType something that returns a Promise, and update all of the callsites.

This might be "fun" because it feeds into willRestore() which has a number of other callers, which also need making async, etc. etc...

(In reply to Mike Conley (:mconley) (:⚙️) from comment #0)

The problem here is that if we're still in the midst of loading the file, this getter will return NO_SESSION, and then cache the value, so that even if there was a session, SessionStartup will claim one doesn't exist. That sounds like a great way of losing a session.

Hm, tbf, this can also only happen if the user doesn't have session restore enabled, right? https://searchfox.org/mozilla-central/rev/6e4dc22cb30c9ffbfee917268c42b17ab8534b91/browser/components/sessionstore/SessionStartup.sys.mjs#386-387,393

Flags: needinfo?(mconley)

Yes, that's true - it looks like that first branch can be computed correctly synchronously (it's not waiting for anything from the SessionFile).

Flags: needinfo?(mconley)

The severity field is not set for this bug.
:dao, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(dao+bmo)
Severity: -- → S3
Flags: needinfo?(dao+bmo)
Priority: -- → P2
Whiteboard: [fidefe-session-restore]
You need to log in before you can comment on or make changes to this bug.