Bug 1354800 - Account for re-entry to removeTab function for tab close timing probes. r?dao
MozReview-Commit-ID: G47xEqSgB7d
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2540,18 +2540,28 @@
// the tab closed. In order to capture as much of the time we care
// about with these stopwatches, but also in order to avoid any
// unnecessary work (since calculating whether or not we're going
// to do the animation might involved a style flush), we start
// stopwatches for both the animating and non-animating case. When
// we decide that we're animating, we cancel the non-animating case,
// and vice-versa. Then, in _endRemoveTab, we "finish" both
// stopwatches, which is a no-op for cancelled stopwatches.
- TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_ANIM_MS", aTab);
- TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
+ //
+ // Note that removeTab might be re-entrant, as we currently spin an
+ // event loop while waiting for remote browsers to tell us whether or
+ // not we're allowed to unload them via permitUnload. This means that
+ // subsequent calls to removeTab will also have these stopwatches
+ // on file. There's also the case that the tab was animating closed,
+ // and removeTab was called on it before it completed. In either case,
+ // we skip (re)starting the stopwatches.
+ if (!aTab._pendingPermitUnload && !aTab.closing) {
+ TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_ANIM_MS", aTab);
+ TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
+ }
if (aParams) {
var animate = aParams.animate;
var byMouse = aParams.byMouse;
var skipPermitUnload = aParams.skipPermitUnload;
}
window.maybeRecordAbandonmentTelemetry(aTab, "tabClosed");