Bug 1510418 - Use TelemetryStopwatch.running instead of custom _tabSwitchStopWatchRunning flag. r=Ehsan
authorDão Gottwald <dao@mozilla.com>
Tue, 27 Nov 2018 21:53:13 +0000
changeset 504915 7bebcd679d58f09ef3c7e77026d42f82a6467f01
parent 504914 5992e36db33e3a7cd79de87fea30dfede2a5a1ef
child 504916 628d20bae43fbdfcf6ec3cee2c34cf3dd42626a6
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1510418
milestone65.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 1510418 - Use TelemetryStopwatch.running instead of custom _tabSwitchStopWatchRunning flag. r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D13126
browser/modules/AsyncTabSwitcher.jsm
--- a/browser/modules/AsyncTabSwitcher.jsm
+++ b/browser/modules/AsyncTabSwitcher.jsm
@@ -131,18 +131,16 @@ class AsyncTabSwitcher {
     // For telemetry, keeps track of what most recently cleared
     // the loadTimer, which can tell us something about the cause
     // of tab switch spinners.
     this._loadTimerClearedBy = "none";
 
     this._useDumpForLogging = false;
     this._logInit = false;
 
-    this._tabSwitchStopWatchRunning = false;
-
     this.window.addEventListener("MozAfterPaint", this);
     this.window.addEventListener("MozLayerTreeReady", this);
     this.window.addEventListener("MozLayerTreeCleared", this);
     this.window.addEventListener("TabRemotenessChange", this);
     this.window.addEventListener("sizemodechange", this);
     this.window.addEventListener("occlusionstatechange", this);
     this.window.addEventListener("SwapDocShells", this, true);
     this.window.addEventListener("EndSwapDocShells", this, true);
@@ -432,17 +430,16 @@ class AsyncTabSwitcher {
             // completion.
             this.switchPaintId = this.window.windowUtils.lastTransactionId + 1;
           } else {
             // We're making the tab visible even though we haven't yet got layers for it.
             // It's hard to know which composite the layers will first be available in (and
             // the parent process might not even get MozAfterPaint delivered for it), so just
             // give up measuring this for now. :(
             TelemetryStopwatch.cancel("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window);
-            this._tabSwitchStopWatchRunning = false;
           }
 
           this.tabbrowser._adjustFocusAfterTabSwitch(showTab);
           this.maybeActivateDocShell(this.requestedTab);
         }
       }
 
       // This doesn't necessarily exist if we're a new window and haven't switched tabs yet
@@ -738,22 +735,21 @@ class AsyncTabSwitcher {
   }
 
   // Fires when we paint the screen. Any tab switches we initiated
   // previously are done, so there's no need to keep the old layers
   // around.
   onPaint(event) {
     if (this.switchPaintId != -1 &&
         event.transactionId >= this.switchPaintId) {
-      if (this._tabSwitchStopWatchRunning) {
+      if (TelemetryStopwatch.running("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window)) {
         let time = TelemetryStopwatch.timeElapsed("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window);
         if (time != -1) {
           TelemetryStopwatch.finish("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window);
           this.log("DEBUG: tab switch time including compositing = " + time);
-          this._tabSwitchStopWatchRunning = false;
         }
       }
       this.addMarker("AsyncTabSwitch:Composited");
       this.switchPaintId = -1;
     }
 
     this.maybeVisibleTabs.clear();
   }
@@ -1076,21 +1072,20 @@ class AsyncTabSwitcher {
    * Telemetry and Profiler related helpers for recording tab switch
    * timing.
    */
 
   startTabSwitch() {
     TelemetryStopwatch.cancel("FX_TAB_SWITCH_TOTAL_E10S_MS", this.window);
     TelemetryStopwatch.start("FX_TAB_SWITCH_TOTAL_E10S_MS", this.window);
 
-    if (this._tabSwitchStopWatchRunning) {
+    if (TelemetryStopwatch.running("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window)) {
       TelemetryStopwatch.cancel("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window);
     }
     TelemetryStopwatch.start("FX_TAB_SWITCH_COMPOSITE_E10S_MS", this.window);
-    this._tabSwitchStopWatchRunning = true;
     this.addMarker("AsyncTabSwitch:Start");
     this.switchInProgress = true;
   }
 
   /**
    * Something has occurred that might mean that we've completed
    * the tab switch (layers are ready, paints are done, spinners
    * are hidden). This checks to make sure all conditions are