Bug 200418 - Ping loads should not prevent page caching
Summary: Ping loads should not prevent page caching
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:
 
Reported: 2019-08-03 09:22 PDT by Chris Dumez
Modified: 2019-08-04 16:28 PDT (History)
10 users (show)

See Also:


Attachments
Patch (17.03 KB, patch)
2019-08-03 09:33 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-08-03 09:22:47 PDT
Ping loads should not prevent page caching.
Comment 1 Radar WebKit Bug Importer 2019-08-03 09:23:13 PDT
<rdar://problem/53901632>
Comment 2 Chris Dumez 2019-08-03 09:33:38 PDT
Created attachment 375486 [details]
Patch
Comment 3 Darin Adler 2019-08-04 11:02:14 PDT
Comment on attachment 375486 [details]
Patch

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

Two suggestions for refinement later; neither should block landing this exactly as is.

> Source/WebCore/history/PageCache.cpp:466
> +    // Stop all loads again before checking if we can still cache the page after firing the pagehide
> +    // event, since the page may have started ping loads in its pagehide event handler.
> +    for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
> +        if (auto* documentLoader = frame->loader().documentLoader())
> +            documentLoader->stopLoading();
> +    }

Since this says "again" I assume there’s another copy of this loop somewhere. Could we share it rather than writing it out twice?

> Source/WebCore/loader/DocumentLoader.cpp:128
> +static bool shouldPendingCachedResourceLoadPreventPageCache(CachedResource& cachedResource)

I think the local could be named just "resource" since its unambiguous in the context of this sort function.
Comment 4 WebKit Commit Bot 2019-08-04 11:32:51 PDT
Comment on attachment 375486 [details]
Patch

Clearing flags on attachment: 375486

Committed r248265: <https://trac.webkit.org/changeset/248265>
Comment 5 WebKit Commit Bot 2019-08-04 11:32:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 youenn fablet 2019-08-04 16:28:43 PDT
Comment on attachment 375486 [details]
Patch

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

> Source/WebCore/loader/DocumentLoader.cpp:139
> +        return false;

Similarly to prefetch, preloads should probably not prevent entering page cache.
Probably not a huge risk in practice but this would be nice to cover that case as well.
Something like (resource.isLinkPreload() && resource.preloadResult() == CachedResource::PreloadResult::PreloadNotReferenced) might do the trick.