Bug 204912 - Prevent synchronous XHR in beforeunload / unload event handlers
Summary: Prevent synchronous XHR in beforeunload / unload event handlers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://www.chromestatus.com/feature/...
Keywords: InRadar
Depends on: 206315
Blocks:
  Show dependency treegraph
 
Reported: 2019-12-05 14:02 PST by Chris Dumez
Modified: 2020-01-15 14:09 PST (History)
11 users (show)

See Also:


Attachments
Patch (12.86 KB, patch)
2019-12-05 14:39 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (13.71 KB, patch)
2019-12-05 15:41 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.56 KB, patch)
2019-12-06 08:37 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.77 KB, patch)
2019-12-06 10:25 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2019-12-05 14:02:01 PST
Prevent synchronous XHR in beforeunload / unload event handlers. They are terrible for performance and the Beacon API (or Fetch keepalive) are more efficient & supported alternatives.
Comment 1 Radar WebKit Bug Importer 2019-12-05 14:02:42 PST
<rdar://problem/57676394>
Comment 2 Chris Dumez 2019-12-05 14:39:06 PST
Created attachment 384955 [details]
Patch
Comment 3 Chris Dumez 2019-12-05 15:41:59 PST
Created attachment 384970 [details]
Patch
Comment 4 Ryosuke Niwa 2019-12-05 17:01:20 PST
Comment on attachment 384970 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=384970&action=review

> Source/WebCore/loader/DocumentThreadableLoader.cpp:134
> +    if (!m_async && (!document.page() || !document.page()->areSynchronousLoadsAllowed())) {

Seems like we want to put this behind some kind of a setting / feature flag?
Comment 5 Ryosuke Niwa 2019-12-05 17:01:33 PST
Do other browsers forbid this as well?
Comment 6 Sam Weinig 2019-12-06 06:42:04 PST
It seems like if we want to make this kind of change, we should first understand the compatibility story and if it's ok, make a change to HTML5 to standardize this.

Otherwise, it's not clear why this is an ok change to make.
Comment 7 Chris Dumez 2019-12-06 08:12:59 PST
(In reply to Ryosuke Niwa from comment #5)
> Do other browsers forbid this as well?

No, other browsers do not do this at this time.
Comment 8 Chris Dumez 2019-12-06 08:15:05 PST
(In reply to Ryosuke Niwa from comment #5)
> Do other browsers forbid this as well?

Please see https://www.chromestatus.com/feature/4664843055398912
Comment 9 Chris Dumez 2019-12-06 08:16:09 PST
(In reply to Chris Dumez from comment #7)
> (In reply to Ryosuke Niwa from comment #5)
> > Do other browsers forbid this as well?
> 
> No, other browsers do not do this at this time.

Sorry, I meant the opposite. Not sure what happened there:

Chrome has been testing this for a while:
https://www.chromestatus.com/feature/4664843055398912
Comment 10 Chris Dumez 2019-12-06 08:25:28 PST
(In reply to Ryosuke Niwa from comment #4)
> Comment on attachment 384970 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=384970&action=review
> 
> > Source/WebCore/loader/DocumentThreadableLoader.cpp:134
> > +    if (!m_async && (!document.page() || !document.page()->areSynchronousLoadsAllowed())) {
> 
> Seems like we want to put this behind some kind of a setting / feature flag?

Good idea, will do.
Comment 11 Chris Dumez 2019-12-06 08:37:24 PST
Created attachment 385015 [details]
Patch
Comment 12 Chris Dumez 2019-12-06 10:25:38 PST
Created attachment 385025 [details]
Patch
Comment 13 WebKit Commit Bot 2019-12-06 13:05:19 PST
Comment on attachment 385025 [details]
Patch

Clearing flags on attachment: 385025

Committed r253213: <https://trac.webkit.org/changeset/253213>
Comment 14 WebKit Commit Bot 2019-12-06 13:05:21 PST
All reviewed patches have been landed.  Closing bug.