This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12651 - More things should set salvageable to false: XHR, plugins
Summary: More things should set salvageable to false: XHR, plugins
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-12 18:43 UTC by contributor
Modified: 2011-09-29 18:51 UTC (History)
9 users (show)

See Also:


Attachments

Description contributor 2011-05-12 18:43:50 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/complete/history.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#unloading-documents

Comment:
More things should set salvageable. Like XHR. See
<http://trac.webkit.org/browser/trunk/Source/WebCore/history/PageCache.cpp>
for relevant code in safari (thanks ap)

Posted from: 85.227.158.3 by simonp@opera.com
User agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.5.8; U; en) Presto/2.8.131 Version/11.10
Comment 1 Alexey Proskuryakov 2011-05-12 18:50:08 UTC
Obviously, not all WebKit's reasons to prevent page caching need to be standardized, and some of them probably can't be easily deconstructed.

A few cases are hiding under canSuspendActiveDOMObjects(), such as Workers and running IDBTransactions.
Comment 2 Anne 2011-06-24 10:40:57 UTC
Should this be defined in XMLHttpRequest?
Comment 3 Simon Pieters 2011-06-27 07:35:14 UTC
It'd make sense for the XHR spec to cover XHR's interaction here. But there are other things besides XHR.
Comment 4 Michael[tm] Smith 2011-08-04 05:34:25 UTC
mass-move component to LC1
Comment 5 Ian 'Hixie' Hickson 2011-08-17 04:17:18 UTC
I assume you mean "more things should set salvageable _to false_".

I'm happy to add more things, or add hooks for other specs if necessary (I think hooks already exist though).

The only case I could find from the source above that looked relevant is that we can't bfcache a page if anything in its browsing context involves a live plugin.

The other things didn't look like things we should add to the spec, though. For example, why would the use of shared workers affect it? Why would encrypted pages be affected?
Comment 6 Boris Zbarsky 2011-08-17 14:09:32 UTC
Gecko bfcaches pages with plug-ins and just stops/restarts the plug-in.  It's caused us a few compat issues, but not very many, and there's been work to provide a better stop/restart in NPAPI so that plug-ins can play nicely with bfcache.

So I don't think we should add plug-ins to the list of things that make pages not salvageable.
Comment 7 Jonas Sicking (Not reading bugmail) 2011-08-22 20:30:35 UTC
Gecko also doesn't have any XHR specific code. We do however prevent bfcaching of any page which has open network connections.

Potentially ideally we should exempt EventSource from this so network connections held open by a page using EventSource *doesn't* set salvageable to false.

But any other network connections, such as dynamically loaded <img> or XHR causes the salvageable flag to be false.

And for these purposes, "network connections" include connections to the filesystem. So a FileReader which is currently reading a Blob or File will also cause salvageable to be false.
Comment 8 Ian 'Hixie' Hickson 2011-09-21 21:23:38 UTC
Why do you set salvageable to false if you've got an open network connection up, rather than just finishing the download (especially if it's only been going for a few milliseconds)?

Note that the browser is always allowed to throw out a bfcached page; I could add some text saying that if a network connection is prematurely aborted then it should be thrown out, if you like.
Comment 9 Boris Zbarsky 2011-09-22 01:45:00 UTC
> Why do you set salvageable to false if you've got an open network connection
> up, rather than just finishing the download

Several reasons:

1)  For just about every network connection, download completion needs to trigger an event handler, which is a really weird thing to do in an unloaded page.  This is certainly the case for XHR.

2)  At least in Gecko, the data structure tracking in-progress network access is attached to the WindowProxy (because you have to be able to treat a load as starting in one page but finishing in another).  So on page transition requests have to be canceled so as not to affect onload in the new page.

3)  Having unloaded pages consume network resources is very much contrary to user expectations.

> (especially if it's only been going for a few milliseconds)?

I don't see why this is an "especially" or why it matters.
Comment 10 Ian 'Hixie' Hickson 2011-09-29 18:51:26 UTC
(In reply to comment #9)
> 1)  For just about every network connection, download completion needs to
> trigger an event handler, which is a really weird thing to do in an unloaded
> page.  This is certainly the case for XHR.

The way the spec is written today, the task for that event would get queued, and the event loop skips tasks from documents that aren't active, so the event would fire once the document was made active again.


> 2)  At least in Gecko, the data structure tracking in-progress network access
> is attached to the WindowProxy (because you have to be able to treat a load as
> starting in one page but finishing in another).  So on page transition 
> requests have to be canceled so as not to affect onload in the new page.

Ok.


> 3)  Having unloaded pages consume network resources is very much contrary to
> user expectations.

Yeah, I completely agree that if the download is using up resources then it deserves to be dropped if it's not active.


> > (especially if it's only been going for a few milliseconds)?
> 
> I don't see why this is an "especially" or why it matters.

I figure some browsers will want the following model to work:

 - user is on a page.
 - every now and then, the page causes a very brief network request.
 - the user clicks a link on the page.
 - user then hits the back button.

If the user clicked the link while no network request was active, hitting the back button will be fast, because it'll be bfcached. But if a request _was_ active, then it'll be slow. The user can't tell the difference.


Anyway. Per spec, the browser is allowed to discard a document in the bfcache whenever it wants. I think we should only be aborting documents and setting their salvageable flag to false in cases where there is really no way that bfcache can work (e.g. when there's an unload event handler). We shouldn't be disallowing cases where implementation difficulties mean that it doesn't work today, but where one could imagine another browser, or the same browser after lots of work, doing it in a way that allowed bfcache.

(Note that one exception to this currently is that the spec requires document loads that are in-progress during a navigation to be aborted, regardless of whether it's truly necessary or not. I added that recently, because every browsers does it. Maybe it was a mistake, though.)


EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: It doesn't seem any of the cases listed in this bug are cases where we cannot imagine a browser successfully using bfcache, so we shouldn't preclude it in those cases. I'm happy to add cases if there are some that are actual problems in all cases.