Closed Bug 1774937 Opened 2 months ago Closed 2 months ago

Unresponsive script warning appears much too late

Categories

(DevTools :: Debugger, defect, P2)

Firefox 101
defect

Tracking

(firefox104 fixed)

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: _+bugzilla, Assigned: ochameau)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0

Steps to reproduce:

I currently have a broken JavaScript to debug that hangs and causes an endless loop somewhere. I waited for Firefox to show me the "unresponsive script" warning, but nothing happened. It keps circling, the F12 debugger tab remained empty. So I clicked the "stop load" button. Once, then many times. Pressed the Escape key. It kept circling. Then after a minute or so, the warning appeared. I clicked Stop and after another while, it actually stopped.

My "dom.max_script_run_time" setting is at its default value of 10. Is that seconds or minutes? According to web sources, it should be seconds. So it doesn't work. It takes much longer. And stopping also doesn't work immediately, it again takes some time.

Expected results:

I'd think that the warning appears more or less exactly after the specified time span. A few seconds more should be okay, but not a multiple of it. And when I say "stop", what's the use in deferring that? Is there some major vote going on inside the browser and the script has a blocking vote?

I can't provide the broken script here (it's really huge and has dependencies). If you don't have a non-terminating script, I may try to provide one.

The Bugbug bot thinks this bug should belong to the 'DevTools::Debugger' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Debugger
Product: Firefox → DevTools

Alex reproduced the issue, the popup appears way too late, even with a simple infinite loop.
The issue probably lies before DevTools are involved, but we should provide a reduced test case and some pointers about where this popup is triggered.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(poirot.alex)

Will find existing bug reports about this popup.

Flags: needinfo?(jdescottes)

Yes dom.max_script_run_time is in seconds and note that you might have to at least click once in the tab in order to ensure the dialog to be shown.

But there is a couple of things being imperfect/broken around this "slow script warning" feature:

  • The "debug script" button is only shown in Developer Edition. In any other Firefox build (release/nigthly) you would only see "Stop". So you could only break in the loop in Dev edition.
  • The "debug script" button only works if DevTools were already opened before opening the page that loops.
  • There is an exception that seems to almost always make the debugger fail to break.
Flags: needinfo?(poirot.alex)

I filed Bug 1692491 a while ago, but at that time I was waiting for https://mozilla-hub.atlassian.net/browse/FFXP-106 (not sure if that's openly visible, but it was a project to improve the UI/UX of the slow script feature).

Flags: needinfo?(jdescottes)
See Also: → 1692491
Assignee: nobody → poirot.alex

We weren't waiting for interrupt to have fully paused the thread
before trying to resume when the state was "attached".

The test doesn't really cover this fix as mochitest head files will force loading gDevTools...
To properly cover that we would have to have this test in another file and folder without any head.
This will make it hard to reuse Debugger test helpers. Let's assume we cover the modified feature
while not covering the very precise regression I fix here.

Severity: -- → S3
Priority: -- → P2
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/39fe8edd4b83
Show the debug slow script button if DevTools are opened on all releases. r=jdescottes,dthayer
https://hg.mozilla.org/integration/autoland/rev/a472404e52f7
[devtools] Fix breaking on slow scripts. r=jdescottes
https://hg.mozilla.org/integration/autoland/rev/a545a227cec1
[devtools] Allow to debug slow script without having devtools opened beforehand. r=jdescottes
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
You need to log in before you can comment on or make changes to this bug.