Bug 1572671 - Don't load content process server startup script if it was already loaded. r=ochameau.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 28 Aug 2019 06:37:18 +0000
changeset 490307 9a111ae683fae0100c145a333e8fdd95086a2ef1
parent 490306 d3fe24ea630981ac7b2fe46912a03aff2665e1b6
child 490308 4e083e209fcf065338557ae95605d570351da33b
child 490335 2e8bbe940e424ae3a7d7094f556e12da71a4901f
push id36499
push userbtara@mozilla.com
push dateWed, 28 Aug 2019 09:39:56 +0000
treeherdermozilla-central@4e083e209fcf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1572671 - Don't load content process server startup script if it was already loaded. r=ochameau. Previously, we were simply having a flag on the ContentProcessConnector that we would flip once we loaded the content process server startup script. This was working fine until multi-proxy browser console. Each time we open the Browser Console, we create a new loader in a new compartment. Which means in the end we'll have a new ContentProcessConnector instance, and the flag would be resetted, and thus we would load a new content process server startup script, which finally, would emit some packet twice, and thus would break how we manage new packet in the client. This patch fixes that by replacing the flag by checking if the script was already loaded. Differential Revision: https://phabricator.services.mozilla.com/D43618
--- a/devtools/server/connectors/content-process-connector.js
+++ b/devtools/server/connectors/content-process-connector.js
@@ -16,33 +16,28 @@ loader.lazyRequireGetter(
 loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
 const ContentProcessConnector = {
-  // Flag to check if the content process server startup script was already loaded.
-  _contentProcessServerStartupScriptLoaded: false,
    * Start a DevTools server in a content process (representing the entire process, not
    * just a single frame) and add it as a child server for an active connection.
   startServer(connection, mm, onDestroy) {
     return new Promise(resolve => {
       const prefix = connection.allocID("content-process");
       let actor, childTransport;
       mm.addMessageListener("debug:content-process-actor", function listener(
       ) {
-        // Arbitrarily choose the first content process to reply
-        // XXX: This code needs to be updated if we use more than one content process
         mm.removeMessageListener("debug:content-process-actor", listener);
         // Pipe Debugger message from/to parent/child via the message manager
         childTransport = new ChildDebuggerTransport(mm, prefix);
         childTransport.hooks = {
           onPacket: connection.send.bind(connection),
           onClosed() {},
@@ -53,23 +48,25 @@ const ContentProcessConnector = {
         dumpn(`Start forwarding for process with prefix ${prefix}`);
         actor = msg.json.actor;
       // Load the content process server startup script only once.
-      if (!this._contentProcessServerStartupScriptLoaded) {
+      const isContentProcessServerStartupScripLoaded = Services.ppmm
+        .getDelayedProcessScripts()
+        .some(([uri]) => uri === CONTENT_PROCESS_SERVER_STARTUP_SCRIPT);
+      if (!isContentProcessServerStartupScripLoaded) {
         // Load the process script that will receive the debug:init-content-server message
-        this._contentProcessServerStartupScriptLoaded = true;
       // Send a message to the content process server startup script to forward it the
       // prefix.
       mm.sendAsyncMessage("debug:init-content-server", {
         prefix: prefix,