More aggressively abort slow scripts when the tab (browser/docshell) goes away
Categories
(Core :: DOM: Navigation, enhancement, P3)
Tracking
()
People
(Reporter: Gijs, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: perf:resource-use, perf:responsiveness)
In bug 1711381 I ran into some issues where a page that repeatedly called prompt()
was able to trigger some broken behaviour.
When I wrote an automated test, I mimicked the original testcase by writing a dumb infinite loop:
while (!prompt("Prompt forever"));
(this loops when the automated test closes the parent window, as the prompt()
starts returning undefined or empty string immediately without actually prompting, when the browser
containing the document goes away)
Unfortunately, this then broke subsequent tests. Specifically, when switching tabs, test code waits for TabSwitchDone
which is fired by the AsyncTabSwitcher code when a tab switch completes. However, despite my test closing the browser window (whose sole tab had the about:blank page with the infinite loop), the JS in that content process kept spinning, and this held up the async tab switcher code. Making the async tab switcher code more resilient to a slow script in the content process is bug 1711740.
However, ISTM that we should also be much more aggressive aborting running scripts in these situations. We should be able to determine if there were unload
or beforeunload
handlers or similar, and if not, I think ending the script from the interrupt handling code after 500ms or 1s would be fine. Judging by the timeouts that resulted on infra, we appear to be waiting much longer - I haven't checked, but I suspect we're waiting for the slow script timeout, at which point we send a notification to the parent, which will then go "oh, that script has no browser anymore to prompt the user about it - kill it!".
Of course, this runs the risk that the script we abort was about to add such unload/beforeunload handlers, but I think the cost/benefit here is such that we shouldn't really care about that.
Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Description
•