From d622a3d445d021b0202a964d0dfcf126c82dab05 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Tue, 6 Aug 2019 23:31:55 +0000 Subject: [PATCH] Bug 1569060 - Add layout debugger command to dump process IDs. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D39437 --HG-- extra : moz-landing-system : lando --- browser/base/content/tabbrowser.js | 33 +++++++------------ .../layout-debug/ui/content/layoutdebug.js | 14 ++++++++ .../layout-debug/ui/content/layoutdebug.xul | 1 + toolkit/modules/E10SUtils.jsm | 25 ++++++++++++++ 4 files changed, 52 insertions(+), 21 deletions(-) diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index cff7cfe2ecec..e3b5467bfc76 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -4779,28 +4779,19 @@ label = tab._fullLabel || tab.getAttribute("label"); } if (AppConstants.NIGHTLY_BUILD) { - if ( - tab.linkedBrowser && - tab.linkedBrowser.isRemoteBrowser && - tab.linkedBrowser.frameLoader - ) { - label += - " (pid " + tab.linkedBrowser.frameLoader.remoteTab.osPid + ")"; - - // If we're running with fission enabled, try to include PID - // information for every remote subframe. - if (gFissionBrowser) { - let pids = new Set(); - let stack = [tab.linkedBrowser.browsingContext]; - while (stack.length) { - let bc = stack.pop(); - stack.push(...bc.getChildren()); - if (bc.currentWindowGlobal) { - pids.add(bc.currentWindowGlobal.osPid); - } + if (tab.linkedBrowser) { + // On Nightly builds, show the PID of the content process, and if + // we're running with fission enabled, try to include PIDs for + // every remote subframe. + let [contentPid, ...framePids] = E10SUtils.getBrowserPids( + tab.linkedBrowser, + gFissionBrowser + ); + if (contentPid) { + label += " (pid " + contentPid + ")"; + if (gFissionBrowser) { + label += " [F " + framePids.join(", ") + "]"; } - - label += " [F " + Array.from(pids).join(", ") + "]"; } } } diff --git a/layout/tools/layout-debug/ui/content/layoutdebug.js b/layout/tools/layout-debug/ui/content/layoutdebug.js index de7485406046..acc4994f5c36 100644 --- a/layout/tools/layout-debug/ui/content/layoutdebug.js +++ b/layout/tools/layout-debug/ui/content/layoutdebug.js @@ -74,6 +74,20 @@ class Debugger { this._attached = true; } + dumpProcessIDs() { + let parentPid = Services.appinfo.processID; + let [contentPid, ...framePids] = E10SUtils.getBrowserPids( + gBrowser, + gFissionBrowser + ); + + dump(`Parent pid: ${parentPid}\n`); + dump(`Content pid: ${contentPid || "-"}\n`); + if (gFissionBrowser) { + dump(`Subframe pids: ${framePids.length ? framePids.join(", ") : "-"}\n`); + } + } + get visualDebugging() { return this._visualDebugging; } diff --git a/layout/tools/layout-debug/ui/content/layoutdebug.xul b/layout/tools/layout-debug/ui/content/layoutdebug.xul index f6d3f97dbc84..cd23b2575fd1 100644 --- a/layout/tools/layout-debug/ui/content/layoutdebug.xul +++ b/layout/tools/layout-debug/ui/content/layoutdebug.xul @@ -80,6 +80,7 @@ + diff --git a/toolkit/modules/E10SUtils.jsm b/toolkit/modules/E10SUtils.jsm index 2a7f8abae387..87048c200b19 100644 --- a/toolkit/modules/E10SUtils.jsm +++ b/toolkit/modules/E10SUtils.jsm @@ -774,6 +774,31 @@ var E10SUtils = { } return deserialized; }, + + /** + * Returns the pids for a remote browser and its remote subframes. + */ + getBrowserPids(aBrowser, aRemoteSubframes) { + if (!aBrowser.isRemoteBrowser || !aBrowser.frameLoader) { + return []; + } + let tabPid = aBrowser.frameLoader.remoteTab.osPid; + let pids = new Set(); + if (aRemoteSubframes) { + let stack = [aBrowser.browsingContext]; + while (stack.length) { + let bc = stack.pop(); + stack.push(...bc.getChildren()); + if (bc.currentWindowGlobal) { + let pid = bc.currentWindowGlobal.osPid; + if (pid != tabPid) { + pids.add(pid); + } + } + } + } + return [tabPid, ...pids]; + }, }; XPCOMUtils.defineLazyGetter(