Bug 205069

Summary: There should be no user-noticeable delay when closing a tab
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, mitz, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Chris Dumez 2019-12-10 09:57:04 PST
There should be no user-noticeable delay when closing a tab. To achieve this, use a timeout of 50ms for doing the IPC handshake with the WebContent process, instead of 500ms.
Comment 1 Radar WebKit Bug Importer 2019-12-10 09:57:50 PST
<rdar://problem/57797494>
Comment 2 Chris Dumez 2019-12-10 10:00:50 PST
Created attachment 385276 [details]
Patch
Comment 3 Chris Dumez 2019-12-11 08:30:25 PST
ping review?
Comment 4 WebKit Commit Bot 2019-12-11 14:05:28 PST
Comment on attachment 385276 [details]
Patch

Clearing flags on attachment: 385276

Committed r253395: <https://trac.webkit.org/changeset/253395>
Comment 5 WebKit Commit Bot 2019-12-11 14:05:30 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 mitz 2019-12-11 18:36:11 PST
What’s the user-visible symptom when the UI process misses the 50ms deadline? Can you share any field data on how often it would happen?
Comment 7 Chris Dumez 2019-12-11 19:06:26 PST
(In reply to mitz from comment #6)
> What’s the user-visible symptom when the UI process misses the 50ms
> deadline? Can you share any field data on how often it would happen?

It would not be the UIProcess missing the deadline but rather the WebProcess missing the deadline. From the UIProcess point of view, after 50ms we close the tab no matter what, even if the page’s script is still handling the beforeunload event.

The idea is that we give the page’s script a chance to tell us if we should display an unload confirm prompt but not at the cost of a delaying the tab closing for more than 50ms. The script has 50ms to tell us to show the prompt or we close the tab without showing such prompts.

I do not have data on how common this will happen in practice. However, there is error logging in release builds if it happens. Also, from my own personal experience unload confirm prompt are not very common on the Web.
Comment 8 mitz 2019-12-11 20:55:33 PST
(In reply to Chris Dumez from comment #7)

Thanks for the detailed response, Chris!

> (In reply to mitz from comment #6)
> > What’s the user-visible symptom when the UI process misses the 50ms
> > deadline? Can you share any field data on how often it would happen?
> 
> It would not be the UIProcess missing the deadline but rather the WebProcess
> missing the deadline.

Sorry, my silly mistake.

> From the UIProcess point of view, after 50ms we close
> the tab no matter what, even if the page’s script is still handling the
> beforeunload event.
> 
> The idea is that we give the page’s script a chance to tell us if we should
> display an unload confirm prompt but not at the cost of a delaying the tab
> closing for more than 50ms. The script has 50ms to tell us to show the
> prompt or we close the tab without showing such prompts.

Makes sense.

> I do not have data on how common this will happen in practice. However,
> there is error logging in release builds if it happens. Also, from my own
> personal experience unload confirm prompt are not very common on the Web.

I also rarely get prompted on close (even with the current 500ms delay).