Bug 202434 - XMLHttpRequest sometimes prevents pages from entering the back/forward cache
Summary: XMLHttpRequest sometimes prevents pages from entering the back/forward cache
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 202293
  Show dependency treegraph
 
Reported: 2019-10-01 14:37 PDT by Chris Dumez
Modified: 2019-10-03 14:29 PDT (History)
7 users (show)

See Also:


Attachments
Patch (5.97 KB, patch)
2019-10-01 15:44 PDT, 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-10-01 14:37:12 PDT
XMLHttpRequest sometimes prevents pages from entering the back/forward cache.
Comment 1 Radar WebKit Bug Importer 2019-10-01 14:37:38 PDT
<rdar://problem/55890340>
Comment 2 Chris Dumez 2019-10-01 15:44:32 PDT
Created attachment 379958 [details]
Patch
Comment 3 Geoffrey Garen 2019-10-03 13:44:29 PDT
Comment on attachment 379958 [details]
Patch

r=me

Isn't it also the case that the document refuses to cache if it has not fired the load event yet? It seems like tight coupling for an XHR object to maintain invariants on behalf of the document.
Comment 4 Chris Dumez 2019-10-03 13:46:02 PDT
(In reply to Geoffrey Garen from comment #3)
> Comment on attachment 379958 [details]
> Patch
> 
> r=me
> 
> Isn't it also the case that the document refuses to cache if it has not
> fired the load event yet? It seems like tight coupling for an XHR object to
> maintain invariants on behalf of the document.

It is true for the main frame but not necessarily true for subframes (that were added later on, after the load event had fired in the main frame).
Comment 5 Geoffrey Garen 2019-10-03 13:48:49 PDT
> > Isn't it also the case that the document refuses to cache if it has not
> > fired the load event yet? It seems like tight coupling for an XHR object to
> > maintain invariants on behalf of the document.
> 
> It is true for the main frame but not necessarily true for subframes (that
> were added later on, after the load event had fired in the main frame).

If a subframe has not loaded yet, and we cancel its loads in order to enter the page cache, doesn't that present the same concern -- that the subframe document will fire its load event while in the page cache?
Comment 6 Chris Dumez 2019-10-03 13:51:37 PDT
(In reply to Geoffrey Garen from comment #5)
> > > Isn't it also the case that the document refuses to cache if it has not
> > > fired the load event yet? It seems like tight coupling for an XHR object to
> > > maintain invariants on behalf of the document.
> > 
> > It is true for the main frame but not necessarily true for subframes (that
> > were added later on, after the load event had fired in the main frame).
> 
> If a subframe has not loaded yet, and we cancel its loads in order to enter
> the page cache, doesn't that present the same concern -- that the subframe
> document will fire its load event while in the page cache?

No, the load event would fire before entering PageCache, which is when we stop the loads. The issue here is that XMLHttpRequest stops its load in the "suspend" function (where script is not allowed to run). This can be refactored further so that XMLHttpRequest no longer stops its loads in suspend though. I can look into it in a follow-up.
Comment 7 Geoffrey Garen 2019-10-03 13:57:58 PDT
Sounds good.
Comment 8 WebKit Commit Bot 2019-10-03 14:29:50 PDT
Comment on attachment 379958 [details]
Patch

Clearing flags on attachment: 379958

Committed r250678: <https://trac.webkit.org/changeset/250678>
Comment 9 WebKit Commit Bot 2019-10-03 14:29:51 PDT
All reviewed patches have been landed.  Closing bug.