Closed Bug 1728290 Opened 4 years ago Closed 3 years ago

Inconsistent behavior on `debugger;` statements when React Developer Tools webextension is installed

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(firefox100 verified)

VERIFIED FIXED
100 Branch
Tracking Status
firefox100 --- verified

People

(Reporter: jdescottes, Assigned: wartmanm)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

Needs to be verified by others but for me, it seems that the debugger behaves strangely on some breakpoints when the React Developer Tools webextension is installed.

STRs:

ER: Should resume
AR: Need to click a second time for the debugger to resume. Note that very rarely, it works with a single click. But 95% of the time I need to click twice, or it goes into a weird state and I need to click both on the resume button from the overlay and the one from the toolbox. Or I get no overlay, etc....

After disabling React DevTools from the DevTools settings (don't even have to uninstall them), breakpoints work a lot more consistently.

Some features such as disable all breakpoints also seem to behave oddly.

Changing severity to S3 because hard to trigger (need specific extension)

Severity: -- → S3
Flags: needinfo?(hmanilla)
Priority: -- → P3

I can consistently reproduce the overlay issue, after first reload ...

Another STR (without setTimeout)

  1. With react devtoper tools extension installed (as above)
  2. https://phantom-breakpoints.glitch.me/
  3. Open the fx devtools debugger
  4. Reload the page
  5. The debugger statement on line 11 should be hit
  6. Click resume

AR
Debugger resumes but the overlay is not cleared (need to click resume in the overlay again to clear)

ER
Debugger resumes and the overlay disappears

Note:
After reloading the page again, everything seems to work properly for me

Flags: needinfo?(hmanilla)

I quickly checked, and it's because once the user resumes (from the top level target), we hit https://searchfox.org/mozilla-central/rev/3fa5cc437a4937c621ea068ba5dc246f75831633/devtools/server/actors/thread.js#491 from the webextension target that is created for the React webextension

I'd like to work on this, please.

The issue with breakpoints being hit inconsistently has been really frustrating for me. If you add a breakpoint, then reload the page, it will get paused on twice. Even if you remove it, it'll still pause once until you reload again. Occasionally, the pause overlay doesn't appear, so there's no way to continue at all.

It seems like when devtools.inspectedWindow.eval() is called for the first time, the devtools commands created in ExtensionParent attach a debugger and start listening for breakpoints and debugger statements, even though this isn't necessary. My plan is to extend the createdForBrowserConsole check in TargetMixin._attachAndInitThread() to also not attach for webconsole-owned descriptors.

  • Is this a good approach? It works fine, but createdForBrowserConsole is described as a hack. I'm not sure if I should be increasing the reliance on it.
  • Should the test go in devtools/client/debugger or toolkit/components/extensions?

Hi Matthew,
Thanks for looking into this. Sure you can work on it.

(In reply to mattheww from comment #4)

I'd like to work on this, please.

Thanks for looking into this. Sure you can work on it. Assigning to you.

The issue with breakpoints being hit inconsistently has been really frustrating for me. If you add a breakpoint, then reload the page, it will get paused on twice. Even if you remove it, it'll still pause once until you reload again. Occasionally, the pause overlay doesn't appear, so there's no way to continue at all.

It seems like when devtools.inspectedWindow.eval() is called for the first time, the devtools commands created in ExtensionParent attach a debugger and start listening for breakpoints and debugger statements, even though this isn't necessary. My plan is to extend the createdForBrowserConsole check in TargetMixin._attachAndInitThread() to also not attach for webconsole-owned descriptors.

  • Is this a good approach? It works fine, but createdForBrowserConsole is described as a hack. I'm not sure if I should be increasing the reliance on it.
  • Should the test go in devtools/client/debugger or toolkit/components/extensions?

Seems like you are on the right path.
Pinging Alex has more experience in this area, so should be able to answer and guide.

Flags: needinfo?(poirot.alex)
Assignee: nobody → wartmanm

The main trouble we might get here is about disabling the thread actor.
WebExtension usages of the DevTools is only about the console actor and InspectedWindow commands, which relates to a dedicated actor.
While the console can interact with the thread actor, it should also work without it. As that's what happen with the browser console.

So it should be fine disabling it for the WebExtension targets. But we should have some extensive manual testing.

Now regarding how to disable the thread actor, you are on the right track.
We should either:

  • have TargetMixin._attachAndInitThread bail out on descriptorFront.createdForBrowserConsole || descriptorFront.isForWebExtension (you would have to set this isForWebExtension boolean from TabDescriptorFront.setIsForWebExtension.
    or
  • rename createdForBrowserConsole to disableThreadActor/doNotCreateThreadActor/doNotAttachThreadActor/... and have both CommandsFactory.createdForBrowserConsole and CommandsFactory.forTab set this flag on the descriptor.
    I have a slight preference for the second.
    The hack wasn't really about disable the thread actor, but rather about how to convey information between CommandsFactory down to TargetMixin. Putting a flag coming out of the blue like this feels hacky. But I don't have much better suggestion.

Regarding the tests, I would rather see it in the debugger folder as there isn't much specifics around webextensions.
The following test might be a useful template to start from:
https://searchfox.org/mozilla-central/source/devtools/client/debugger/test/mochitest/browser_dbg-content-script-sources.js

Flags: needinfo?(poirot.alex)
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ab2f0e774375 don't connect devtools webextensions to ThreadActors r=ochameau
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch

I managed to reproduce this bug on Firefox 98.0(20220304153049) on macOS 11. Confirmed as fixed on Firefox 100.0b8(20220419190903) and Nightly 101.0a1(20220419214607) on macOS 11, Win10 64-bits and Linux x86_64(Ubuntu 20.04).

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: