Bug 1528276 - Do not destroy the DebuggerServer in non-e10s when last frame connection is closed r=ochameau a=lizzard
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 27 Feb 2019 19:17:37 +0000
changeset 516223 e089d94139746ea06377fb7f71df25e55e3edf69
parent 516222 d8af25e59ccfc1a05b2b220b3174cf19a88533a1
child 516224 a8cd0839de6b06b2ed1c8fcf7bea7b2d1526574c
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, lizzard
bugs1528276, 1521052
milestone66.0
Bug 1528276 - Do not destroy the DebuggerServer in non-e10s when last frame connection is closed r=ochameau a=lizzard When reviewing https://bugzilla.mozilla.org/show_bug.cgi?id=1521052 I did not think about Firefox for Android which is not using e10s. This means the main DebuggerServer will be killed when there are no connections left. Happy to discuss more about the preferred solution. This is a regression in 66 and I hope to uplift a fix for this. Differential Revision: https://phabricator.services.mozilla.com/D20830
devtools/server/main.js
devtools/server/startup/frame.js
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -58,16 +58,23 @@ var DebuggerServer = {
   chromeWindowType: "navigator:browser",
 
   /**
    * Allow debugging chrome of (parent or child) processes.
    */
   allowChromeProcess: false,
 
   /**
+   * Flag used to check if the server can be destroyed when all connections have been
+   * removed. Firefox on Android runs a single shared DebuggerServer, and should not be
+   * closed even if no client is connected.
+   */
+  keepAlive: false,
+
+  /**
    * We run a special server in child process whose main actor is an instance
    * of FrameTargetActor, but that isn't a root actor. Instead there is no root
    * actor registered on DebuggerServer.
    */
   get rootlessServer() {
     return !this.createRootActor;
   },
 
--- a/devtools/server/startup/frame.js
+++ b/devtools/server/startup/frame.js
@@ -123,17 +123,17 @@ try {
       connections.clear();
     });
 
     // Destroy the server once its last connection closes. Note that multiple frame
     // scripts may be running in parallel and reuse the same server.
     function destroyServer() {
       // Only destroy the server if there is no more connections to it. It may be used
       // to debug another tab running in the same process.
-      if (DebuggerServer.hasConnection()) {
+      if (DebuggerServer.hasConnection() || DebuggerServer.keepAlive) {
         return;
       }
       DebuggerServer.off("connectionchange", destroyServer);
       DebuggerServer.destroy();
     }
     DebuggerServer.on("connectionchange", destroyServer);
   })();
 } catch (e) {