From 9cf72260e9dc7f1021b3a946f5eff1a061117de4 Mon Sep 17 00:00:00 2001 From: Charlie Reis Date: Wed, 1 Mar 2023 17:47:45 +0000 Subject: [PATCH] Add per-profile tab and frame counts to chrome://process-internals. Also removes AgentSchedulingGroupHost ID for now, since we don't currently have more than one per process. It can be shown again in the future if we start creating more than one. Bug: 850087 Change-Id: Icdc7ef263f3c076539d47dcdb4fd36ecd7525e9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4293054 Reviewed-by: Alex Moshchuk Commit-Queue: Charlie Reis Cr-Commit-Position: refs/heads/main@{#1111683} --- .../resources/process/process_internals.html | 38 ++++++++++++-- .../resources/process/process_internals.ts | 51 +++++++++++++++++-- 2 files changed, 80 insertions(+), 9 deletions(-) diff --git a/content/browser/resources/process/process_internals.html b/content/browser/resources/process/process_internals.html index 2c837dbc9620c6..f625c10a7aeec7 100644 --- a/content/browser/resources/process/process_internals.html +++ b/content/browser/resources/process/process_internals.html @@ -76,10 +76,40 @@
-
Legend:
-
Frame[process_id:routing_id:agent_scheduling_group_id]: - SI:site_instance_id, whether process is locked to a - site, site: site_url | url: +
This page only contains information about the + current profile.
+ + + + + + + + + + + + + + + + + + + + + + + +
Tab Count:The number of WebContents objects in this + profile.
Frame Count:The number of RenderFrameHosts in this + profile. Note that this does not include RenderFrameHosts that + are speculative or pending deletion.
OOPIF Count:The number of out-of-process iframes in + this profile (as a subset of the Frame Count).
Process Count:The number of renderer processes in this + profile.
+
Legend: Frame[process_id:routing_id]: + SI:site_instance_id, is process locked to a + site?, site: site_url | url: last_committed_url
diff --git a/content/browser/resources/process/process_internals.ts b/content/browser/resources/process/process_internals.ts index 672140a2f18764..0327d4780e4515 100644 --- a/content/browser/resources/process/process_internals.ts +++ b/content/browser/resources/process/process_internals.ts @@ -103,6 +103,14 @@ async function loadProcessCountInfo() { */ let treeViewRoot: CrTreeElement|null = null; +/** + * Accumulators for tracking frame and process counts. Reset in + * loadWebContentsInfo. + */ +let totalFrameCount: number = 0; +let totalCrossProcessFrameCount: number = 0; +let processIdSet: Set = new Set(); + /** * Initialize and return |treeViewRoot|. */ @@ -117,13 +125,22 @@ function getTreeViewRoot(): CrTreeElement { /** * Initialize and return a tree item representing a FrameInfo object and - * recursively creates its subframe objects. + * recursively creates its subframe objects. For subframes, pass the parent + * frame's process ID in `parentProcessId`. */ -function frameToTreeItem(frame: FrameInfo): +function frameToTreeItem(frame: FrameInfo, parentProcessId: number = -1): {item: CrTreeItemElement, count: number} { + // Count out-of-process iframes. + const isCrossProcessFrame: boolean = + parentProcessId !== -1 && parentProcessId !== frame.processId; + if (isCrossProcessFrame) { + totalCrossProcessFrameCount++; + } + processIdSet.add(frame.processId); + // Compose the string which will appear in the entry for this frame. - let itemLabel = `Frame[${frame.processId}:${frame.routingId}:${ - frame.agentSchedulingGroupId}]:`; + const prefix = isCrossProcessFrame ? 'OOPIF' : 'Frame'; + let itemLabel = `${prefix}[${frame.processId}:${frame.routingId}]:`; if (frame.type === FrameInfo_Type.kBackForwardCache) { itemLabel += ` bfcached`; } else if (frame.type === FrameInfo_Type.kPrerender) { @@ -133,6 +150,8 @@ function frameToTreeItem(frame: FrameInfo): itemLabel += ` SI:${frame.siteInstance.id}`; if (frame.siteInstance.locked) { itemLabel += ', locked'; + } else { + itemLabel += ', unlocked'; } if (frame.siteInstance.siteUrl) { itemLabel += `, site:${frame.siteInstance.siteUrl.url}`; @@ -164,7 +183,7 @@ function frameToTreeItem(frame: FrameInfo): let frameCount = 1; for (const subframe of frame.subframes) { - const result = frameToTreeItem(subframe); + const result = frameToTreeItem(subframe, frame.processId); const subItem = result.item; const count = result.count; @@ -230,6 +249,8 @@ function webContentsToTreeItem(webContents: WebContentsInfo): } item.label = itemLabel; + totalFrameCount += activeCount + cachedCount + prerenderCount; + return item; } @@ -254,9 +275,29 @@ function populateWebContentsTab(infos: WebContentsInfo[]) { * current browser profile. The result is passed to populateWebContentsTab. */ async function loadWebContentsInfo() { + // Reset frame counts. + totalFrameCount = 0; + totalCrossProcessFrameCount = 0; + processIdSet = new Set(); + assert(pageHandler); const {infos} = await pageHandler.getAllWebContentsInfo(); populateWebContentsTab(infos); + + // Post tab, frame, and process counts. + const tabCount = document.querySelector('#tab-count'); + assert(tabCount); + tabCount.innerText = String(infos.length); + const frameCount = document.querySelector('#frame-count'); + assert(frameCount); + frameCount.innerText = String(totalFrameCount); + const oopifCount = document.querySelector('#oopif-count'); + assert(oopifCount); + oopifCount.innerText = String(totalCrossProcessFrameCount); + const processCount = + document.querySelector('#profile-process-count'); + assert(processCount); + processCount.innerText = String(processIdSet.size); } /**