Bug 1346854 - Delay network listening until toolbox open. r=ochameau
Once upon a time (
bug 862341), we decided to enable network listening by
default in DevTools.
In a general sense, that's fine. When you open a toolbox, we listen to that
tab and stop listening when the toolbox closes.
GCLI / Developer Toolbar is quite different, though. It connects to the whole
browser. This meant that enabling GCLI would start listening to network
activity in *every* tab (even though it doesn't have any way to even use that
data). This of course will slow down performance with all the extra tracking
and eat up memory with the tracked request data.
In this change, we move the step to enable network listening into the toolbox,
which seems more like what we intended anyway.
MozReview-Commit-ID: 2UYoQtWCAE1
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -420,19 +420,17 @@ TabTarget.prototype = {
this._remote.reject("Unable to attach to the console");
return;
}
this.activeConsole = consoleClient;
this._remote.resolve(null);
};
let attachConsole = () => {
- this._client.attachConsole(this._form.consoleActor,
- [ "NetworkActivity" ],
- onConsoleAttached);
+ this._client.attachConsole(this._form.consoleActor, [], onConsoleAttached);
};
if (this.isLocalTab) {
this._client.connect()
.then(() => this._client.getTab({ tab: this.tab }))
.then(response => {
this._form = response.tab;
this._url = this._form.url;
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -410,16 +410,24 @@ Toolbox.prototype = {
}, this._URL);
// Optimization: fire up a few other things before waiting on
// the iframe being ready (makes startup faster)
// Load the toolbox-level actor fronts and utilities now
yield this._target.makeRemote();
+ // Start tracking network activity on toolbox open for targets such as tabs.
+ // (Workers and potentially others don't manage the console client in the target.)
+ if (this._target.activeConsole) {
+ yield this._target.activeConsole.startListeners([
+ "NetworkActivity",
+ ]);
+ }
+
// Attach the thread
this._threadClient = yield attachThread(this);
yield domReady.promise;
this.isReady = true;
let framesPromise = this._listFrames();
Services.prefs.addObserver("devtools.cache.disabled", this._applyCacheSettings,