Bug 1492830 - change worker target threadClient attach pattern to be the same as other targets; r=jdescottes
authoryulia <ystartsev@mozilla.com>
Wed, 15 May 2019 09:47:59 +0000
changeset 474044 91d4f30e0ddad63c153baee71e8bc496987204f4
parent 474043 7811523177894d6658e481200b644686126d7fd1
child 474045 02a438fa11a8b1be6b0db28aa3f5c39b7ff6f8e8
push id36022
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:55:16 +0000
treeherdermozilla-central@96802be91766 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1492830
milestone68.0a1
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 1492830 - change worker target threadClient attach pattern to be the same as other targets; r=jdescottes The worker target is the only target to have a unique thread client attach. It doesn't look like there is a specific reason for this. In order to remove redundancy from target thread instantiation, I have made this follow the same pattern as elsewhere, so we can merge the "resume" method into the thread attach method on target. Differential Revision: https://phabricator.services.mozilla.com/D29805
devtools/client/debugger/src/client/firefox/workers.js
--- a/devtools/client/debugger/src/client/firefox/workers.js
+++ b/devtools/client/debugger/src/client/firefox/workers.js
@@ -23,32 +23,29 @@ export async function updateWorkerClient
   }
 
   const newWorkerClients = {};
 
   const { workers } = await tabTarget.listWorkers();
   for (const workerTargetFront of workers) {
     try {
       await workerTargetFront.attach();
-      const [, workerThread] = await workerTargetFront.attachThread(options);
+      const threadActorID = workerTargetFront._threadActor;
+      if (workerClients[threadActorID]) {
+        newWorkerClients[threadActorID] = workerClients[threadActorID];
+      } else {
+        const [, workerThread] = await workerTargetFront.attachThread(options);
+        workerThread.resume();
 
-      const actor = workerThread.actor;
-      if (workerClients[actor]) {
-        if (workerClients[actor].thread != workerThread) {
-          console.error(`Multiple clients for actor ID: ${workerThread.actor}`);
-        }
-        newWorkerClients[actor] = workerClients[actor];
-      } else {
         addThreadEventListeners(workerThread);
-        workerThread.resume();
 
         const consoleFront = await workerTargetFront.getFront("console");
         await consoleFront.startListeners([]);
 
-        newWorkerClients[actor] = {
+        newWorkerClients[workerThread.actor] = {
           url: workerTargetFront.url,
           thread: workerThread,
           console: consoleFront
         };
       }
     } catch (e) {
       // If any of the workers have terminated since the list command initiated
       // then we will get errors. Ignore these.