Bug 1652613 - record whether the user switched away from the tab while it was hung, r=mconley
☠☠ backed out by 7f26efea615b ☠ ☠
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 22 Jul 2020 22:28:05 +0000
changeset 541853 76b5a5d243d16d4cd0ba9b640fdd4ae9d5f8555b
parent 541852 6f98c9b019206c198b145bc102905745fa37d3f7
child 541854 1245f6702e787c214f7ac9e9d71776a18e54b936
push id122532
push usergijskruitbosch@gmail.com
push dateThu, 23 Jul 2020 22:13:38 +0000
treeherderautoland@76b5a5d243d1 [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,26 @@ 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);
+        if (r) {
+          let info = this._activeReports.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 +688,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