Bug 1770527 - [devtools] Fix and ensure that browser toolbox close when closing Firefox. r=jdescottes

Either of the two changes fixes the reported issue.

On the frontend side, we weren't listening to DevToolsClient/connection close.
So that there was no guarantee that the Browser Toolbox would close if the remote connection is lost.
We were actually depending on Launcher.close to be called (it is called correctly)
and complete `dbgProcess.kill()`, which apparently doesn't always work during shutdown.

It looks like `SubProcess.kill` was made slower and didn't always had time to complete
because on the server side, the Parent Process Target actor was trying
to switch from browser.xhtml to chrome://extensions/content/dummy.xhtml.
But this document is being destroyed and the target as well as all children
actors and watchers were still trying to debug stuff and were all throwing.

Correctly destroying the parent process target actor when browser.xhtml is closed
seems to allow SubProcess.kill to complete...
And thanks to client's closed listener, even if we stop killing the process,
the browser toolbox process will close by itself.

Differential Revision: https://phabricator.services.mozilla.com/D148128
This commit is contained in:
Alexandre Poirot 2022-06-02 20:26:43 +00:00
Родитель a77018108b
Коммит 782ca9d04e
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -258,6 +258,10 @@ async function bindToolboxHandlers() {
gToolbox.once("destroyed", quitApp);
window.addEventListener("unload", onUnload);
// If the remote connection drops, firefox was closed
// In such case, force closing the browser toolbox
gClient.once("closed", quitApp);
if (Services.appinfo.OS == "Darwin") {
// Badge the dock icon to differentiate this process from the main application
// process.

Просмотреть файл

@ -971,7 +971,11 @@ const windowGlobalTargetPrototype = {
// If the original top level document we connected to is removed,
// we try to switch to any other top level document
const rootDocShells = this.docShells.filter(d => {
return d != this.docShell && this._isRootDocShell(d);
// Ignore docshells without a working DOM Window.
// When we close firefox we have a chrome://extensions/content/dummy.xhtml
// which is in process of being destroyed and we might try to fallback to it.
// Unfortunately docshell.isBeingDestroyed() doesn't return true...
return d != this.docShell && this._isRootDocShell(d) && d.DOMWindow;
});
if (rootDocShells.length > 0) {
const newRoot = rootDocShells[0];