Bug 1652613 - record whether the user switched away from the tab while it was hung, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 24 Jul 2020 00:55:34 +0000
changeset 541859 74d2da5438778a6f885443709dab3806c44c708a
parent 541858 5bbd29a7db14dd5fb5b8eafeb4e8d4056c6f392d
child 541860 8ec86ac40c7ad7d78b432f583ec96a6af5f8b649
push id37633
push userccoroiu@mozilla.com
push dateFri, 24 Jul 2020 09:32:06 +0000
treeherdermozilla-central@141543043270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1652613
milestone80.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
toolkit/components/telemetry/Events.yaml
--- a/browser/modules/ProcessHangMonitor.jsm
+++ b/browser/modules/ProcessHangMonitor.jsm
@@ -427,16 +427,17 @@ var ProcessHangMonitor = {
       Services.telemetry.recordEvent(
         "slow_script_warning",
         "shown",
         "content",
         null,
         {
           end_reason: endReason,
           hang_duration: "" + hangDuration,
+          n_tab_deselect: "" + info.deselectCount,
           uri_type,
           uptime,
           wait_count: "" + info.waitCount,
         }
       );
     } catch (ex) {
       Cu.reportError(ex);
     }
@@ -633,18 +634,28 @@ var ProcessHangMonitor = {
     );
   },
 
   handleEvent(event) {
     let win = event.target.ownerGlobal;
 
     // 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);
     }
   },
 
   /**
    * Handle a potentially new hang report. If it hasn't been seen
    * before, show a notification for it in all open XUL windows.
    */
@@ -679,16 +690,17 @@ var ProcessHangMonitor = {
       Services.telemetry.getHistogramById("SLOW_SCRIPT_NOTICE_COUNT").add();
     } else if (report.hangType == report.PLUGIN_HANG) {
       // On non-e10s we have sufficient plugin telemetry probes,
       // so PLUGIN_HANG_NOTICE_COUNT is only probed on e10s.
       Services.telemetry.getHistogramById("PLUGIN_HANG_NOTICE_COUNT").add();
     }
 
     this._activeReports.set(report, {
+      deselectCount: 0,
       lastReportFromChild: now,
       waitCount: 0,
     });
     this.updateWindows();
   },
 
   clearHang(report) {
     this._recordTelemetryForReport(report, "cleared");
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -2289,16 +2289,17 @@ slow_script_warning:
     objects: [
       "browser",
       "content",
     ]
     extra_keys:
       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).
 
 webrtc.ui:
   share_display:
     objects:
       - screen
       - window