unload event handler does not always complete
Reported by
daniel.i...@oracle.com,
May 25 2017
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0 Steps to reproduce the problem: Feature trying to implement is to log user out of system when closing tab/browser 1. Implement event handler for unload event - Event handler sends synchronous XMLHttpRequest to server 2. Open page in browser 3. click the "X" close button on browser - Note: This works as expected 100% of time when closing a tab or window and other chrome tabs/windows remain open What is the expected behavior? Browser will wait for response from XMLHttpRequest.send (which is synchronous) to complete before shutting down browser What went wrong? This works roughly half the time. There's a slight delay while server responds, then browser shuts down. The rest of the time, there's no delay, the browser just shuts down and the server never receives the request. Did this work before? N/A Chrome version: 58.0.3029.110 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Shockwave Flash 25.0 r0 This is incredibly difficult to debug since we're in the middle of the unload handler. You can't manipulate the DOM, no can you break in the debugger. By adding states to local storage, I found that the handler is called and makes it XMLHttpRequest.send call, but then shuts down. The server never receives the call.
,
May 26 2017
This issue seems to be out of TE-scope. Hence adding label TE-NeedsTriageHelp for further investigation. Thanks...!!
,
May 26 2017
The browser will only give render processes (and so web pages) a limited amount of time to clean up on shutdown before killing them forcibly. If I remember correctly, there are also some shutdown scenarios in which the unload event will not be fired at all. Assigning +kinuko to confirm whether or not this is the intended behaviour. Please reassign if further work is needed.
,
May 26 2017
how much time are we talking about. In successful case, it takes about 1.5 seconds to shut down. In the error case, it shuts down immediately. The code is in a try/catch/finally block, and sometimes on failure (not consistently), the finally block isn't even executed. Don't know if that's helpful or not...
,
May 29 2017
It is kinda working-as-expected, unload event handler is not and cannot be very reliable actually. (We're trying to come up with better page lifecycle events that fire earlier, because firing things right before something gets killed can't be very reliable- +panicker@ for that part) |
||||
►
Sign in to add a comment |
||||
Comment 1 by nyerramilli@chromium.org
, May 26 2017