Bug 1346854 - Delay network listening until toolbox open. r=ochameau draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 23 Mar 2017 14:34:37 -0500
changeset 562804 425e3a12e70969df91d44ddea72bdc0e96cc551b
parent 562803 a8a257ba1903eb2a5be7b7cf098be4eb6ff4a8ee
child 562805 7f8012b128e952a348e76b2ed2946a729a0357e4
push id54118
push userbmo:jryans@gmail.com
push dateFri, 14 Apr 2017 09:13:53 +0000
reviewersochameau
bugs1346854, 862341
milestone55.0a1
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
devtools/client/framework/target.js
devtools/client/framework/toolbox.js
--- 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,