Closed Bug 1687645 Opened 4 years ago Closed 4 years ago

Debugger is broken when using --jsdebugger with mochitests

Categories

(DevTools :: Debugger, defect, P2)

defect

Tracking

(firefox-esr78 unaffected, firefox85 unaffected, firefox86 unaffected, firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox85 --- unaffected
firefox86 --- unaffected
firefox87 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

After fixing the main issue for Bug 1676618, I still managed to get a broken debugger when using --jsdebugger with mochitests.

For instance:

If you do the STRs correctly (and are a bit lucky) the debugger will pause, but no source will be visible. The reason behind that is that we are processing a WorkerTargetDescriptor which has no thread attached, and therefore the following call throws:

const threadFront = await targetFront.getFront("thread");

(https://searchfox.org/mozilla-central/rev/2c06b16a0c15ae340a0532e319cbf89ef9d21b68/devtools/shared/resources/legacy-listeners/source.js#40)

The form of the WorkerTargetDescriptor looks like:

{
  actor:"server1.conn0.workerDescriptor218",
  threadActor:null,
  id:"ea89ba08-7b76-064c-a706-cc5e4cc06a7a",
  url:"resource://gre/modules/PageThumbsWorker.js",
  traits:{},
  type:0
}

(in comparison, other worker target descriptors will have a non null thread actor, as well as a console actor)

This can silently fail, if the worker is processed via onTargetAvailable. But if the target is already present when we start watching for the "source" resource, then it will be processed via the following stack:

module.exports@resource://devtools/shared/resources/legacy-listeners/source.js:42:15
_watchResourcesForTarget@resource://devtools/shared/resources/resource-watcher.js:739:41
_startListening@resource://devtools/shared/resources/resource-watcher.js:690:26
watchResources@resource://devtools/shared/resources/resource-watcher.js:149:20

Called by https://searchfox.org/mozilla-central/rev/2c06b16a0c15ae340a0532e319cbf89ef9d21b68/devtools/client/debugger/src/client/firefox.js#48

This is executed in the middle of the debugger startup, so without investigating much further, I guess it makes sense that the debugger will be broken since we failed in the middle of the initialization.

Few things we should consider:

    1. investigate why this specific worker target descriptor has no thread attached?
    1. isolate each call to _watchResourcesForTarget to avoid one faulty target breaking everything
    1. potentially bail in the legacy source listener if getFront("thread") fails (depends on the outcome of investigating item 1)

Also another item to look at: debugger UI initialization should not silently fail. We have an error in the middle of panel.open, we should log a proper error message. Maybe show an error in the DevTools notification bar?

There is an interesting twist to those STRs.

If you start on the webconsole rather than the debugger, the first call to watchResources will be made from the source map service. So in that case, the debugger UI will not fail to start. Maybe it will miss sources but it will be less broken. Based on this I think we should really make the resource-watcher code a bit safer, because it might be called from various places and it will be hard to handle all those potential error paths.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

This issue became more visible after introducing the breakpoint resource 1662129. It's legacy listener consistently crashes when attaching to a mochitest.

Let's repurpose.

Regressed by: 1662129
Summary: Source legacy listener throws on WorkerTargetDescriptor with no thread → Debugger is broken when using --jsdebugger with mochitests
Has Regression Range: --- → yes

investigate why this specific worker target descriptor has no thread attached?

So the worker which has no thread is still being attached to. This issue can occur if a TargetList consumer uses getAllTargets, and calls this method while we are in the middle of attaching to a target. We can fix this with something like https://phabricator.services.mozilla.com/D102313 . The idea is simply to avoid making "unattached" targets available from getAllTargets.

isolate each call to _watchResourcesForTarget to avoid one faulty target breaking everything

I think this still makes sense, the downside is that we might let some errors slip. For instance here, even if the try/catch allows --jsdebugger to work, it hides the fact that we are missing a WorkerTarget.

Priority: P3 → P2
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/db4a7d1c8e79 [devtools] Try/catch calls to legacy resource listeners r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: