From eabaeb4c02dbaafa32c27aaedf16a25b9fbe2bdc Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 24 Jul 2020 00:55:34 +0000 Subject: [PATCH] Bug 1652613 - record whether the user switched away from the tab while it was hung, r=mconley Differential Revision: https://phabricator.services.mozilla.com/D84343 --- browser/modules/ProcessHangMonitor.jsm | 14 +++++++++++++- toolkit/components/telemetry/Events.yaml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/browser/modules/ProcessHangMonitor.jsm b/browser/modules/ProcessHangMonitor.jsm index 6e7feb31ee0f..f2b5126e31b6 100644 --- a/browser/modules/ProcessHangMonitor.jsm +++ b/browser/modules/ProcessHangMonitor.jsm @@ -432,6 +432,7 @@ var ProcessHangMonitor = { { end_reason: endReason, hang_duration: "" + hangDuration, + n_tab_deselect: "" + info.deselectCount, uri_type, uptime, wait_count: "" + info.waitCount, @@ -638,8 +639,18 @@ var ProcessHangMonitor = { // If a new tab is selected or if a tab changes remoteness, then // we may need to show or hide a hang notification. - if (event.type == "TabSelect" || event.type == "TabRemotenessChange") { + if (event.type == "TabSelect" && event.detail.previousTab) { + // If we've got a notification, check the previous tab's report and + // indicate the user switched tabs while the notification was up. + let r = + this.findActiveReport(event.detail.previousTab.linkedBrowser) || + this.findPausedReport(event.detail.previousTab.linkedBrowser); + if (r) { + let info = this._activeReports.get(r) || this._pausedReports.get(r); + info.deselectCount++; + } + } this.updateWindow(win); } }, @@ -684,6 +695,7 @@ var ProcessHangMonitor = { } this._activeReports.set(report, { + deselectCount: 0, lastReportFromChild: now, waitCount: 0, }); diff --git a/toolkit/components/telemetry/Events.yaml b/toolkit/components/telemetry/Events.yaml index fd7eada5cb42..17b5a33cc3f2 100644 --- a/toolkit/components/telemetry/Events.yaml +++ b/toolkit/components/telemetry/Events.yaml @@ -2294,6 +2294,7 @@ slow_script_warning: end_reason: Why the warning was hidden (user action, the process becoming responsive again, the browser quitting, etc.) wait_count: How many times the user elected to wait. hang_duration: How long we believe the hang continued (ms). + n_tab_deselect: How many times the user switched away from a tab affected by this hang. uri_type: The kind of script URL that hung. uptime: How long the notification was up (ms).