Open Bug 1471903 Opened 7 years ago Updated 1 year ago

Add pref for auto-stopping slow scripts?

Categories

(Core :: DOM: Core & HTML, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: jujjyl, Unassigned)

Details

Currently when dom.max_script_run_time is exceeded, the slow script banner pops up, prompting user to Stop or Wait execution. When user presses Stop, there is a call stack that gets printed to console, telling where the stop occurred. That call stack is precious to allow debugging slow script conditions. In automated test runners there is nobody to press Stop (but the test runners have their own watchdogs that kill Firefox wholesale when slow script occurs). This means that the test runner is unable to obtain a call stack when it needs to kill the script. Would it be possible to add a dom.auto_stop_slow_scripts pref, which if enable, would automatically cause all slow scripts to stop as if user had pressed Stop on the banner? That way the code flow would print callstack of the script to console, that might give clues to the source where the slow script occurred. This would help debugging slow scripts in automated testing environments, as it is sometimes difficult to reproduce "phantom-like" slow script occurrences on local dev machines. Searching through DXR and about:config, was not able to find if such a pref would have existed already?
The "dom.always_stop_slow_scripts" preference looks promising [1], but I haven't tested it locally. [1] https://searchfox.org/mozilla-central/rev/d2966246905102b36ef5221b0e3cbccf7ea15a86/dom/base/nsGlobalWindowInner.cpp#5429-5431
Hah, good find! I just read XPCJSContext::InterruptCallback() looking for such a hidden pref (I didn't venture into nsGlobalWindowInner::ShowSlowScriptDialog()) so I just wrote the 3-line patch to add it. I wonder if it's worth making this pref more discoverable in about:config by explicitly setting dom.always_stop_slow_scripts=false.
Probably not a bad idea to add it to about:config. It looks like the pref is only mentioned in nsGlobalWindowInner::ShowSlowScriptDialog() and nowhere else in the tree. bug 1101124, which added the pref, also doesn't give any hints why it's a more or less hidden preference.
Priority: -- → P5
Severity: normal → S3
Component: JavaScript Engine → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.