WorkerTargetFront destroy/detach sequence is confusing when opened from openWorkerToolbox
Categories
(DevTools :: General, enhancement, P3)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jdescottes)
Details
Attachments
(2 files)
async openWorkerToolbox(workerTarget, toolId) {
const toolbox = await gDevTools.showToolbox(workerTarget, toolId, Toolbox.HostType.WINDOW);
toolbox.once("destroy", () => workerTarget.detach());
},
I think this is the only toolbox where the client is explicitly calling detach() on the target at the moment.
This leads to calling detach() twice when we close a toolbox inspecting a worker
- target.detach() <- called by devtools-browser via the event listener
- target.destroy() <- called by destroyToolbox
- target.detach() <- called by the destroy(), will log a warning because connection is closed
If we stop calling detach first, then the cleanup is not done correctly because WorkerTargetFront destroy will set a flag "isClosed":
destroy() {
this._isClosed = true;
super.destroy();
}
https://searchfox.org/mozilla-central/source/devtools/shared/fronts/targets/worker.js#44
and this flag will make the detach bail out early:
async detach() {
if (this.isClosed) {
return {};
}
I think the reason behind this flag is that WorkerTargetFront::detach() calls WorkerTargetFront::destroy() which calls TargetMixin::destroy() which calls WorkerTargetFront::detach() (etc... etc...).
I propose to make the detach/destroy sequence closer to the other target fronts and remove the call to detach() from openWorkerToolbox.
Assignee | ||
Comment 1•6 years ago
|
||
Assignee | ||
Comment 2•6 years ago
|
||
Depends on D21673
The test is already relying on events triggered by the destroy method of the front to progress
I don't think having a flag brings anything here.
Assignee | ||
Comment 3•6 years ago
|
||
Try is green except for browser_dbg-windowless-workers-early-breakpoint.js in debug builds, but it seems unrelated. I also have the failure locally without my changes, I guess it's an issue linked to artifact builds, as I get failures such as
JavaScript error: resource://devtools/server/actors/worker/worker-target-actor-list.js, line 57: TypeError: dbg.setDebuggerReady is not a function
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 4•6 years ago
|
||
Assignee | ||
Comment 5•6 years ago
|
||
new try after addressing review comments:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=a96c619056b628403aa3171fae6c542621172524
Comment 7•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c3c262330737
https://hg.mozilla.org/mozilla-central/rev/95c5a6730ef6
Description
•