Bug 1422061 - Prevent performance actor from stopping profiler started by Talos. r=gregtatum
MozReview-Commit-ID: 7PrI9ZwUMtX
--- 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: