Bug 1422061 - Prevent performance actor from stopping profiler started by Talos. r=gregtatum
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 16 Jan 2018 08:26:30 -0800
changeset 454044 cccd776a80d97621554ed046072bc7ea3dc0bdad
parent 454043 47cfae837c499c0dcf95c646114f1b4ee129d7ad
child 454045 7c67b6dd2450bfacbffc44b8eff0444aa4cfcf73
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgregtatum
bugs1422061
milestone59.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 1422061 - Prevent performance actor from stopping profiler started by Talos. r=gregtatum MozReview-Commit-ID: 7PrI9ZwUMtX
devtools/server/performance/profiler.js
--- a/devtools/server/performance/profiler.js
+++ b/devtools/server/performance/profiler.js
@@ -45,16 +45,19 @@ const ProfilerManager = (function () {
   return {
 
     // How often the "profiler-status" is emitted
     _profilerStatusInterval: BUFFER_STATUS_INTERVAL_DEFAULT,
 
     // How many subscribers there
     _profilerStatusSubscribers: 0,
 
+    // Has the profiler ever been started by the actor?
+    started: false,
+
     /**
      * The nsIProfiler is target agnostic and interacts with the whole platform.
      * Therefore, special care needs to be given to make sure different profiler
      * consumers (i.e. "toolboxes") don't interfere with each other. Register
      * the profiler actor instances here.
      *
      * @param Profiler instance
      *        A profiler actor class.
@@ -119,33 +122,38 @@ const ProfilerManager = (function () {
           config.threadFilters.length
         );
       } catch (e) {
         // For some reason, the profiler couldn't be started. This could happen,
         // for example, when in private browsing mode.
         Cu.reportError(`Could not start the profiler module: ${e.message}`);
         return { started: false, reason: e, currentTime };
       }
+      this.started = true;
 
       this._updateProfilerStatusPolling();
 
       let { position, totalSize, generation } = this.getBufferInfo();
       return { started: true, position, totalSize, generation, currentTime };
     },
 
     /**
      * Attempts to stop the nsIProfiler module.
      */
     stop: function () {
       // Actually stop the profiler only if the last client has stopped profiling.
       // Since this is used as a root actor, and the profiler module interacts
       // with the whole platform, we need to avoid a case in which the profiler
       // is stopped when there might be other clients still profiling.
-      if (this.length <= 1) {
+      // Also check for `started` to only stop the profiler when the actor
+      // actually started it. This is to prevent stopping the profiler initiated
+      // by some other code, like Talos.
+      if (this.length <= 1 && this.started) {
         nsIProfilerModule.StopProfiler();
+        this.started = false;
       }
       this._updateProfilerStatusPolling();
       return { started: false };
     },
 
     /**
      * Returns all the samples accumulated since the profiler was started,
      * along with the current time. The data has the following format: