Closed Bug 1806796 Opened 1 year ago Closed 7 months ago

[meta] Missing sources in the debugger when breaking on unload listener

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(firefox120 fixed)

RESOLVED FIXED
120 Branch
Tracking Status
firefox120 --- fixed

People

(Reporter: jdescottes, Assigned: ochameau)

References

(Depends on 2 open bugs, Blocks 1 open bug, Regressed 1 open bug)

Details

(Keywords: meta)

Attachments

(3 files)

Attached file test_case.html

STRs:

  • open test page
  • open devtools > debugger > enable Pause on Exceptions
  • reload

ER: Debugger should show the source where it breaks
AR: No source displayed

Attachment #9309333 - Attachment mime type: text/plain → text/html

Additional information: the debugger breaks, but we cannot resume

Hi,

can I also add that setting a breakpoint on the line that will throw won't work either (on unload too)?

Also:

Not specific to inline scripts, just used that for the sake of simplicity.
Same thing happens with a dedicated script file: https://bug1806796-test-case-script.glitch.me/
And as mentioned above, you get similar symptoms with actual breakpoints or debugger statements (but I get the "resume" popup on top of the overlay in that case, so at least we can recover)

Thanks for filing and STRs.
This is likely related to Bug 1569775.

See Also: → 1569775

So we are having an overall design flaw around navigations.

When we pause we receive "pause" THREAD_STATE resource over there:
https://searchfox.org/mozilla-central/rev/cef96316b3643720769dec96542604c3209f1877/devtools/client/debugger/src/client/firefox.js#160-167
this ends up being stuck on the following code:
https://searchfox.org/mozilla-central/rev/cef96316b3643720769dec96542604c3209f1877/devtools/client/debugger/src/client/firefox/create.js#38-41

  // Because of throttling, the source may be available a bit late.
  const sourceActor = await waitForSourceActorToBeRegisteredInStore(
    frame.where.actor
  );

We never get the related source actor and so never dispatch the paused action.

We never get the related source actor because of how we handle navigation in the debugger.
We clear absolutely everything on early navigation. i.e. when we receive DOCUMENT_EVENT "will-navigate" resource:
https://searchfox.org/mozilla-central/rev/cef96316b3643720769dec96542604c3209f1877/devtools/client/debugger/src/client/firefox.js#176-182
The issue is that this event fires before we hit the breakpoint.
It means that we are hitting a breakpoint:

  • while the related source has already been unregistered from the debugger frontend,
  • we can hit various breakpoints (unload, exceptions) for source of the previous page,
  • I'm even wondering if that's possible to be hitting breakpoint from sources of previous and new page at the same time!

The debugger frontend should probably more wisely clear its state on navigation.
For sources, it would probably be safer to release sources only on target destruction.
Target destruction should fire after all late code of the previous page ran.
This would probably make it easier to leak objects in case of unpexpected errors... but would probably solve various issues on late-running code!

That, instead of clearing them entirely on navigation (will-navigate),
which would clear them too early. Typically before the various unload/navigation/pagehide events are fired.
This was making debugging any of these code impossible.

The severity field is not set for this bug.
:bomsy, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(hmanilla)
Severity: -- → S3
Flags: needinfo?(hmanilla)
Priority: -- → P3
Duplicate of this bug: 1806790
Depends on: 1814177
Depends on: 1822290
Depends on: 1822293
Depends on: 1822295
Depends on: 1822300
Depends on: 1822301
Depends on: 1822302
Depends on: 1822303
Depends on: 1822307
Depends on: 1822310

Most dependencies of this bugs are about ensuring that all reducers will correctly clear themself correctly on each target/thread removal,
so that in this bug we can drop the full clearance of most reducers on NAVIGATE, which happens to be fired before the unload sequence of the previous page.

A preliminary work to help doing that has been to work on bug 1815500, which expose source and sourceActor object directly on all location objects. This will help the reducers identify the related thread of any location and ease cleaning the reducers per thread.

Another independant, but required refactoring will be bug 1822310. The existing "context" assertions will break all actions being asserted during unload event. This will help finally make sense of these context assertions which have been very inconsistent and not handling thread removal properly.

Keywords: meta
Summary: Missing sources in the debugger when breaking on unload listener → [meta] Missing sources in the debugger when breaking on unload listener
Blocks: 1831186
Depends on: 1832567
Depends on: 1832585
Depends on: 1836768
Depends on: 1838443
Depends on: 1838620
Depends on: 1836929
Depends on: 1839318
No longer depends on: 1839318

Also fix an issue where Exception tooltip was always overriden
by the preview tooltip when we were paused.

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a35fad815a44
Bug 1822310 - [devtools] Add tests to cover breakpoints on unload. r=devtools-reviewers,nchevobbe
Regressions: 1855107
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
Depends on: 1861941
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: