Issue metadata
Sign in to add a comment
|
closing window with beforeunload | unload handlers takes too long |
||||||||||||||||||||||||
Issue description
window.addEventListener('beforeunload', function() {
while (true) {}
});
http://plexode.com/eval3/#s=aekVQXANLVQMbA28PQkVFJldGT1UtSlRVnEZTCQhDRkdQU0ZWT01QlwgNAWAJCgFcPU8BAVhJSk1GAQlVU1ZGuFxeu14KHANeAA==
Closing a tab with that code takes ~2 seconds on Chrome 56 on ChromeOS. It should take ~1 second because we trigger hang detection after 1 second.
I'm hitting this on real world content. For example:
1. Go to politico.com
2. ctrl+click to open a half dozen articles in background tabs
3. Wait a second. Then, while the background tabs are still loading, try to close the background tabs by clicking the x button in the tab strip.
Closing each one takes ~2 seconds.
,
Apr 6 2017
What's going on here is that when you close a tab, the browser sends the beforeunload IPC to the render process and starts a 1 second timeout. It fires. It then continues to close the page, which has its own independent 1 second timeout. That one too must fire before the page closes. That's why it's 2 seconds.
,
Aug 22 2017
This feels like it's gotten even slower.
,
Aug 22 2017
Making it so that we cap at a total of one second might be something navigation folks would be interested in fixing. CCing them. :)
,
Aug 25 2017
It seems like we should instead put effort into skipping beforeunload entirely if there aren't any handlers registered for it, in issue 365039. That's likely to improve performance here in the vast majority of cases. With shortening the timeout, we risk losing user data in more cases on a slow machine, so we have to be careful with that.
,
Aug 25 2017
IMO waiting >2 seconds for anything to happen after you try to close a tab is a bad enough user experience that we should be more aggressive. I'm supportive of adding measurement to see how often we kill the tab before the unload is completed though to make sure it doesn't go through the roof.
,
Aug 29 2017
BTW same problem happens on unload too, not just beforeunload (update the demo code to unload). +1 for measurement, I'll look into that aspect.
,
Oct 18 2017
,
Sep 12
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by ojan@chromium.org
, Mar 14 2017