Bug 1340842 - Add FX_TAB_CLOSE_PERMIT_UNLOAD_TIME_MS probe to measure how long it takes to run permitUnload on a tab when asked to close. r?Mossop, data-review=liuche draft
authorMike Conley <mconley@mozilla.com>
Thu, 16 Mar 2017 15:46:15 -0400
changeset 503031 5f36602655fd81daf04692a40556f88c45289b05
parent 503030 46a40c4f8f407947a5ae659ec8b100b15d1772d8
child 550313 f41a7e0df8248ea39cd7d564df93498835159151
push id50459
push usermconley@mozilla.com
push dateWed, 22 Mar 2017 17:36:55 +0000
reviewersMossop
bugs1340842
milestone55.0a1
Bug 1340842 - Add FX_TAB_CLOSE_PERMIT_UNLOAD_TIME_MS probe to measure how long it takes to run permitUnload on a tab when asked to close. r?Mossop, data-review=liuche MozReview-Commit-ID: 1qvhY6g2p9w
browser/base/content/tabbrowser.xml
toolkit/components/telemetry/Histograms.json
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2657,19 +2657,25 @@
 
             if (!aTab._pendingPermitUnload &&
                 !aSkipPermitUnload &&
                 aTab.linkedPanel &&
                 !aAdoptedByTab) {
               // We need to block while calling permitUnload() because it
               // processes the event queue and may lead to another removeTab()
               // call before permitUnload() returns.
+
+              TelemetryStopwatch.start("FX_TAB_CLOSE_PERMIT_UNLOAD_TIME_MS", aTab);
+
               aTab._pendingPermitUnload = true;
               let {permitUnload, timedOut} = browser.permitUnload();
               delete aTab._pendingPermitUnload;
+
+              TelemetryStopwatch.finish("FX_TAB_CLOSE_PERMIT_UNLOAD_TIME_MS", aTab);
+
               // If we were closed during onbeforeunload, we return false now
               // so we don't (try to) close the same tab again. Of course, we
               // also stop if the unload was cancelled by the user:
               if (aTab.closing || (!timedOut && !permitUnload)) {
                 // NB: deliberately keep the _closedDuringPermitUnload set to
                 // true so we keep exiting early in case of multiple calls.
                 return false;
               }
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5043,16 +5043,25 @@
     "alert_emails": ["mconley@mozilla.com", "hkirschner@mozilla.com"],
     "bug_numbers": [1340842],
     "expires_in_version": "60",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 50,
     "description": "Firefox: Time taken from the point of closing a tab (without animation) to the browser element being removed from the DOM. (ms)."
   },
+  "FX_TAB_CLOSE_PERMIT_UNLOAD_TIME_MS": {
+    "alert_emails": ["mconley@mozilla.com", "hkirschner@mozilla.com"],
+    "bug_numbers": [1340842],
+    "expires_in_version": "60",
+    "kind": "exponential",
+    "high": 10000,
+    "n_buckets": 50,
+    "description": "Firefox: Time taken to run permitUnload on a browser during tab close to see whether or not we're allowed to close the tab (ms)."
+  },
   "FX_TAB_ANIM_OPEN_PREVIEW_FRAME_INTERVAL_MS": {
     "expires_in_version": "never",
     "kind": "exponential",
     "low": 7,
     "high": 500,
     "n_buckets": 50,
     "description": "Average frame interval during tab open animation of about:newtab (preview=on), when other tabs are unaffected"
   },