Bug 106147

Summary: ResourceHandle::willLoadFromCache is evil
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: Page LoadingAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, beidson, danw, darin, fmalita, gustavo, japhet, joenotcharles, mifenton, mrobinson, ojan.autocc, rakuco, rwlbuis, tonikitoo, webkit.review.bot, yong.li.webkit
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 108214    
Bug Blocks:    
Attachments:
Description Flags
proposed patch
buildbot: commit-queue-
proposed patch beidson: review+

Description Alexey Proskuryakov 2013-01-04 16:23:37 PST
One can't be certain when using ResourceHandle::willLoadFromCache(), because the resource may be pruned as soon as this function returns. We should try to load from cache unconditionally, and retry if that fails.

<rdar://problem/12948053>
Comment 1 Alexey Proskuryakov 2013-01-04 16:42:08 PST
Created attachment 181407 [details]
proposed patch

Beyond the usual FrameLoader flakiness, I'm worried about my use of stopAllLoaders() in retryAfterFailedCacheOnlyMainResourceLoad(). It seems to work, but I don't know which method of canceling the cache-only request would be fully correct.
Comment 2 Brady Eidson 2013-01-04 16:47:41 PST
Comment on attachment 181407 [details]
proposed patch

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

A somewhat scary change.  Would like an answer to my question and assurance existing layouttests pass.

> Source/WebCore/loader/FrameLoader.cpp:1466
> +    // FIXME: If the resource is a result of form submission and is not cached, the form will be silently resubmitted.
> +    // We should ask the user for confirmation in this case.
>      request.setCachePolicy(ReturnCacheDataElseLoad);

This FIXME is concerning.  Should we even allow this to be a remote possibility?
Comment 3 Alexey Proskuryakov 2013-01-04 17:10:07 PST
> This FIXME is concerning.  Should we even allow this to be a remote possibility?

This is not a change from existing behavior. Just something that I noticed while working on this patch, and decided to make clear in code.

http tests passed for me locally (I did not run the whole suite).
Comment 4 Build Bot 2013-01-04 21:53:05 PST
Comment on attachment 181407 [details]
proposed patch

Attachment 181407 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15706610

New failing tests:
http/tests/cache/history-only-cached-subresource-loads-max-age-https.html
Comment 5 Brady Eidson 2013-01-05 09:16:56 PST
(In reply to comment #4)
> (From update of attachment 181407 [details])
> Attachment 181407 [details] did not pass mac-ews (mac):
> Output: http://queues.webkit.org/results/15706610
> 
> New failing tests:
> http/tests/cache/history-only-cached-subresource-loads-max-age-https.html

Guess we need to figure this one out first :(
Comment 6 Alexey Proskuryakov 2013-01-07 09:47:53 PST
Created attachment 181514 [details]
proposed patch

Indeed.

I've been running tests locally with one more fix that I removed as unrelated prior to submitting the patch. Turns out it's not unrelated!

The additional fix is for non-form case FrameLoader::loadDifferentDocumentItem() - we've been explicitly special casing https subresources to not use stale data on b/f navigation. The reason this worked before was that addExtraFieldsToRequest() was resetting cache policy for b/f navigations after policy delegate.
Comment 7 Alexey Proskuryakov 2013-01-07 10:42:26 PST
Committed <http://trac.webkit.org/changeset/138962>.
Comment 8 Florin Malita 2013-01-29 08:54:52 PST
Apparently this caused https://code.google.com/p/chromium/issues/detail?id=172721

Any ideas about what might be going on?
Comment 9 Alexey Proskuryakov 2013-01-29 09:48:11 PST
Chromium used to hack this functionality in a custom way, this patch changed all ports to a cross-platform implementation. Perhaps there are some vestiges of the old hack remaining and breaking things.
Comment 10 Darin Adler 2013-01-29 10:03:35 PST
kareng@chromium.org rolled this out in http://trac.webkit.org/changeset/141118
Comment 11 Darin Adler 2013-01-29 10:04:03 PST
Oops, my mistake, only on a Chromium branch.
Comment 12 Adam Barth 2013-01-29 12:38:02 PST
I filed bug 108214 about the regression.  Please either fix the regression or roll out your change.
Comment 13 Alexey Proskuryakov 2013-01-29 17:30:00 PST
This is not a fair request.

The chromium port had a long-standing technical debt to the WebKit project due to hacking its implementation in a way that only benefitted their platform at the expense of others. I invested the time to properly implement this in a cross-platform manner. 

This is what chromium developers should have done years ago. The fact that you chose to do an obvious hack instead does not make it others' responsibility to support it.