Bug 1673550 - [devtools] Destroy the thread actor when the worker target actor is destroyed. r=ochameau.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 27 Oct 2020 15:10:46 +0000
changeset 554745 79261eb923741aef8cd3737f1cc7ae6feb0be44b
parent 554744 a8aadd76602fdce2443edaf9345d57967e158ac6
child 554746 51001c4cc73f6183f66eb6d986116155f35347f7
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1673550
milestone84.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 1673550 - [devtools] Destroy the thread actor when the worker target actor is destroyed. r=ochameau. We have to manually call `ThreadActor#exit` as calling `destroy` won't completely destroy it, since it does not call `Actor#destroy`, whereas `ThreadActor#exit` does. Differential Revision: https://phabricator.services.mozilla.com/D94835
devtools/server/actors/targets/worker.js
--- a/devtools/server/actors/targets/worker.js
+++ b/devtools/server/actors/targets/worker.js
@@ -132,21 +132,29 @@ exports.WorkerTargetActor = ActorClassWi
    *        List of all available resources. A resource is a JSON object piped over to the client.
    *        It may contain actor IDs, actor forms, to be manually marshalled by the client.
    */
   notifyResourceAvailable(resources) {
     this.emit("resource-available-form", resources);
   },
 
   destroy() {
+    if (this.threadActor) {
+      // We have to manually call `exit` as calling `destroy` won't completely destroy it.
+      // ThreadActor.destroy do not call protocoljs.Actor.destroy, ThreadActor.exit does it.
+      // We also need do this before destroying _sources as the thread actor may still
+      // use it while cleaning up things.
+      this.threadActor.exit();
+      this.threadActor = null;
+    }
+
     Actor.prototype.destroy.call(this);
 
     if (this._sources) {
       this._sources.destroy();
       this._sources = null;
     }
 
     this.workerGlobal = null;
     this._dbg = null;
-    this.threadActor = null;
     this._consoleActor = null;
   },
 });