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
This commit is contained in:
Cameron McCormack 2019-08-06 23:31:55 +00:00
parent 0e73b6bc4c
commit d622a3d445
4 changed files with 52 additions and 21 deletions

View File

@ -4779,29 +4779,20 @@
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 (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) {
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);
label += " [F " + framePids.join(", ") + "]";
}
}
label += " [F " + Array.from(pids).join(", ") + "]";
}
}
}
if (tab.userContextId) {

View File

@ -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;
}

View File

@ -80,6 +80,7 @@
<menu label="&ldb.DumpMenu.label;"
accesskey="&ldb.DumpMenu.accesskey;">
<menupopup>
<menuitem id="menu_processIDs" label="Process IDs" accesskey="P" oncommand="gDebugger.dumpProcessIDs();" />
<menuitem id="menu_dumpWebShells" label="&ldb.dumpWebShells.label;" accesskey="&ldb.dumpWebShells.accesskey;" oncommand="gDebugger.dumpWebShells();" />
<menuitem id="menu_dumpContent" label="&ldb.dumpContent.label;" accesskey="&ldb.dumpContent.accesskey;" oncommand="gDebugger.dumpContent();" />
<menuitem id="menu_dumpFrames" label="&ldb.dumpFrames.label;" accesskey="&ldb.dumpFrames.accesskey;" oncommand="gDebugger.dumpFrames();" />

View File

@ -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(