browser created in FxAccountsPairingChannel.sys.mjs needs another strong reference
Categories
(Firefox :: Sync, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox137 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 file)
const browser = Services.appShell.createWindowlessBrowser(true);
const {WebSocket} = browser.document.ownerGlobal;
The browser created there is held only by the module global variable.
Once bug 1941472 is fixed, the module globals in system modules behave in the same as the standard ECMAScript modules's globals,
which doesn't necessarily have the same lifetime as the module itself.
Given the browser
variable is not closed over by any function, the object pointed by the variable becomes the target of GC after the top-level execution.
While the WebSocket
holds the reference to the browser's document's property, it doesn't necessarily keep the global alive, and that results in bug 1946592 issue.
Options:
- (a) perform
browser.document.ownerGlobal
inslideFxAccountsPairingChannel
's function, so thatbrowser
is closed over, so that thebrowser
variable gets the same lifetime as the module itself - (b) put
browser
toFxAccountsPairingChannel
's property, so that it gets the same lifetime asFxAccountsPairingChannel
, which has the same lifetime as the module given it's exported
Assignee | ||
Comment 1•1 month ago
|
||
Bug 1941472 is going to change the behavior of module global variables.
The non-exported and not-closed-over global variables doesn't keep the pointed
alive after the top-level script is executed.
Updated•1 month ago
|
Assignee | ||
Comment 2•1 month ago
|
||
for more context, the other consumers stores the browser reference to the consumer's main object.
let windowlessBrowser = Services.appShell.createWindowlessBrowser(true);
...
this._windowlessBrowser = windowlessBrowser;
let wlBrowser = Services.appShell.createWindowlessBrowser(true, flags);
...
this._windowlessContainer = wlBrowser;
this.#browser = Services.appShell.createWindowlessBrowser(
true,
chromeFlags
);
One exception is the following, but it doesn't use the browser after the block, so there's no need to keep it alive.
let windowlessBrowser =
Services.appShell.createWindowlessBrowser(true);
...
} finally {
windowlessBrowser.close();
Description
•