Repository navigation
Conversation
|
EWS run on previous version of this PR (hash 9fcf6d8) Details |
9fcf6d8 to
23bc79e
Compare
|
EWS run on previous version of this PR (hash 23bc79e) Details |
iOS Safer C++ Build #42498 (9fcf6d8)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
iOS Safer C++ Build #42500 (23bc79e)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
macOS Safer C++ Build #123313 (23bc79e)❌ Found 1 failing file with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
23bc79e to
d1d5cba
Compare
|
EWS run on previous version of this PR (hash d1d5cba) Details |
iOS Safer C++ Build #42505 (d1d5cba)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
macOS Safer C++ Build #123318 (d1d5cba)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
d1d5cba to
e1257fd
Compare
|
EWS run on previous version of this PR (hash e1257fd) Details |
e1257fd to
c14efa0
Compare
|
EWS run on previous version of this PR (hash c14efa0) Details |
8fc1a32 to
0527aa3
Compare
|
EWS run on previous version of this PR (hash 0527aa3) Details |
|
EWS run on previous version of this PR (hash 8fc1a32) Details |
|
EWS run on previous version of this PR (hash acce05e) Details |
acce05e to
f2f71f0
Compare
|
EWS run on previous version of this PR (hash f2f71f0) Details |
f2f71f0 to
69a54f4
Compare
|
EWS run on previous version of this PR (hash 69a54f4) Details |
69a54f4 to
e909243
Compare
|
EWS run on previous version of this PR (hash e909243) Details |
e909243 to
c5eda5a
Compare
|
EWS run on previous version of this PR (hash c5eda5a) Details |
c5eda5a to
5b2d8bf
Compare
|
EWS run on previous version of this PR (hash 5b2d8bf) Details |
5b2d8bf to
e5b51ca
Compare
|
EWS run on previous version of this PR (hash e5b51ca) Details |
|
EWS run on previous version of this PR (hash 4e3e0e6) Details |
|
EWS run on previous version of this PR (hash 2cf7f4f) Details |
https://bugs.webkit.org/show_bug.cgi?id=320314 Reviewed by NOBODY (OOPS!). Update the NetworkProcess to preload resources advertised with `Link: rel=preload` in top-level navigation first HTTP 103 response. High-level details: * Preloaded resources are cached in a per-navigation cache, and served only when the consuming fetch matches on URL, CORS mode, credentials mode, cache partition and Vary-dependent request headers. * The preloads also seed the network cache, keyed on the preload request. * Consumed preloaded entries report an "early-hints" initiatorType to Resource Timing. * Preloads that go through cross-origin redirects get dropped. * Currently, scripts aren't loaded under CSP strict-dynamic. That's something we should fix in a followup. The feature is behind the LinkPreloadEarlyHintsEnabled preference, testable and off by default. Imported WPT baselines are updated. Unsupported cases are skipped in TestExpectations: modulepreload, the embed/object destination, and in-flight consumption. Early Hints is Cocoa-only for now (soup receives 103s but doesn't forward them), so the imported suite is skipped on glib. Tests: http/wpt/loading/early-hints/preload-cross-site.h2.window.html http/wpt/loading/early-hints/preload-main-frame-only.h2.window.html http/wpt/loading/early-hints/preload-redirect.h2.window.html imported/w3c/web-platform-tests/loading/early-hints/preload-no-store.h2.window.html Spec: https://html.spec.whatwg.org/multipage/#process-early-hint-headers * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Add the LinkPreloadEarlyHintsEnabled preference gating the feature. * Source/WebCore/loader/LinkHeader.cpp: (WebCore::parameterValueIsOptional): Added; identifies parameters (crossorigin) whose value may be omitted. (WebCore::parseParameterName): Accept a valueless crossorigin rather than returning no name. (WebCore::LinkHeader::LinkHeader): Don't invalidate the header when crossorigin has no value. * Source/WebCore/loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::addResourceTiming): Report an "early-hints" initiator type when the load came from an early hints preload. * Source/WebCore/page/csp/ContentSecurityPolicy.h: Declare decisionForSupportedPreload. * Source/WebCore/page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::decisionForSupportedPreload const): Whether a 103 preload's `as` destination is allowed; nullopt for a destination we don't preload, false for a script we cannot clear because strict-dynamic defers the check. * Source/WebCore/platform/ReferrerPolicy.cpp: (WebCore::parseReferrerPolicy): Export so the NetworkProcess can parse a 103's Referrer-Policy. * Source/WebCore/platform/ReferrerPolicy.h: Export parseReferrerPolicy. * Source/WebCore/platform/network/NetworkLoadMetrics.cpp: (WebCore::NetworkLoadMetrics::NetworkLoadMetrics): Take the new fromEarlyHints flag. (WebCore::NetworkLoadMetrics::updateFromFinalMetrics): Preserve fromEarlyHints when merging interim and final metrics. (WebCore::NetworkLoadMetrics::isolatedCopy const): Copy fromEarlyHints. * Source/WebCore/platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isEarlyHints const): Accessor for the new flag. * Source/WebKit/NetworkProcess/EarlyHintsPreloadCache.h: Added. (WebKit::EarlyHintsPreloadCache::Entry::releaseBuffer): Take ownership of the parked body. * Source/WebKit/NetworkProcess/EarlyHintsPreloadCache.cpp: Added. (WebKit::EarlyHintsPreloadCache::Entry::Entry): Store the preload's fetch mode, cookie policy and varying request headers alongside the response. (WebKit::EarlyHintsPreloadCache::EarlyHintsPreloadCache): Set up the expiration timer. (WebKit::EarlyHintsPreloadCache::registerNavigation): Record the origin and cache partition that issued the 103, resetting the cache when either changes. (WebKit::EarlyHintsPreloadCache::store): Park a completed preload, rejecting stores from a superseded navigation. (WebKit::EarlyHintsPreloadCache::take): Return a parked preload whose URL, mode, cookie policy, cache partition and varying headers match the consumer. (WebKit::EarlyHintsPreloadCache::pruneForFinalResponse): Drop parked preloads the final response's CSP disallows. (WebKit::EarlyHintsPreloadCache::clear): Drop a frame's, or all, parked preloads. (WebKit::EarlyHintsPreloadCache::clearExpiredEntries): Timer callback evicting navigations past their expiry. (WebKit::EarlyHintsPreloadCache::addInFlightPreload): (WebKit::EarlyHintsPreloadCache::settleInFlightPreload): (WebKit::EarlyHintsPreloadCache::hasMatchingInFlightPreload const): (WebKit::EarlyHintsPreloadCache::addInFlightPreloadWaiter): (WebKit::EarlyHintsPreloadCache::settleAll): * Source/WebKit/NetworkProcess/EarlyHintsPreloadTask.h: Added. * Source/WebKit/NetworkProcess/EarlyHintsPreloadTask.cpp: Added. (WebKit::EarlyHintsPreloadTask::create): Create a speculative load carrying its mode, cookie policy and hinting origin. (WebKit::EarlyHintsPreloadTask::EarlyHintsPreloadTask): Ditto. (WebKit::EarlyHintsPreloadTask::start): Start the network load and self-retain until it completes. (WebKit::EarlyHintsPreloadTask::willSendRedirectedRequest): Follow a same-origin redirect; abandon the preload on a cross-origin one. (WebKit::EarlyHintsPreloadTask::didReceiveResponse): Only park a successful (2xx) response. (WebKit::EarlyHintsPreloadTask::didReceiveBuffer): Buffer the body, abandoning the preload past the size cap. (WebKit::EarlyHintsPreloadTask::didFinishLoading): Seed the network cache from the preload's own request, then park the response for later consumption. (WebKit::EarlyHintsPreloadTask::didFailLoading): Discard the preload on failure. (WebKit::EarlyHintsPreloadTask::complete): Tear down the load and drop the self-reference. * Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::startRequest): Consume a matching early hints preload before consulting the disk cache. (WebKit::NetworkResourceLoader::retrieveEarlyHintsPreload): Added; serve a parked preload to a subresource, without requiring a network cache. (WebKit::NetworkResourceLoader::didReceiveResponse): When the navigation received early hints, prune parked preloads against the final response's CSP. (WebKit::NetworkResourceLoader::start): Clear the frame's preloads when a new main-frame navigation begins. (WebKit::NetworkResourceLoader::willSendRedirectedRequestInternal): On a cross-origin main-frame redirect, discard preloads and restart early hints processing. (WebKit::NetworkResourceLoader::sendResultForCacheEntry): Mark the finish metrics as early-hints-served. (WebKit::NetworkResourceLoader::didReceiveInformationalResponse): (WebKit::NetworkResourceLoader::constructPreconnectRequest): (WebKit::NetworkResourceLoader::startPreconnectTask): (WebKit::NetworkResourceLoader::startPreloadTask): (WebKit::NetworkResourceLoader::handleEarlyHintsResponse): * Source/WebKit/NetworkProcess/NetworkResourceLoader.h: Declare retrieveEarlyHintsPreload and track whether this load was served from the early hints preload cache. * Source/WebKit/NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): Own the early hints preload cache. (WebKit::NetworkSession::earlyHintsPreloadCache): Checked accessor for the cache. (WebKit::NetworkSession::lowMemoryHandler): Drop parked preloads under memory pressure. * Source/WebKit/NetworkProcess/NetworkSession.h: Declare the early hints preload cache. * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Serialize the fromEarlyHints metrics flag. * Source/WebKit/Sources.txt: Build the new files. * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add the new files. * LayoutTests/TestExpectations: Skip the early hints cases WebKit does not support. * LayoutTests/platform/glib/TestExpectations: Skip the imported early hints suite; the feature is Cocoa-only. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/404-with-early-hints.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/coep-early-hints-require-corp-final-none.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/csp-early-hints-absent-final-absent.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/csp-early-hints-absent-final-allowed.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/csp-early-hints-allowed-final-absent.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/csp-early-hints-allowed-final-allowed.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/multiple-early-hints-responses.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-fetchpriority.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-finished-before-final-response.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-finished-while-receiving-final-response-body.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-initiator-type.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/redirect-cross-origin-between-early-hints.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/redirect-same-origin-between-early-hints.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/redirect-same-origin.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/referrer-policy-no-referrer.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/referrer-policy-origin-when-cross-origin.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/referrer-policy-origin.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/referrer-policy-same-origin.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/referrer-policy-unsafe-url.h2.window-expected.txt: Rebaselined for Early Hints preload support. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-no-store.h2.window.html: Added. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-no-store.h2.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/resources/preload-no-store.html: Added. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/resources/no-store.js: Added. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/resources/no-store.js.headers: Added. * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/resources/w3c-import.log: * LayoutTests/http/wpt/loading/early-hints/preload-redirect.h2.window.js: Added; a preload redirected cross-origin is abandoned, so the document's own request loads the resource. (promise_test.async t): * LayoutTests/http/wpt/loading/early-hints/preload-redirect.h2.window.html: Added. * LayoutTests/http/wpt/loading/early-hints/preload-redirect.h2.window-expected.txt: Added. * LayoutTests/http/wpt/loading/early-hints/preload-main-frame-only.h2.window.js: Added; a 103 delivered on a child navigable navigation is ignored. (promise_test.async t): * LayoutTests/http/wpt/loading/early-hints/preload-main-frame-only.h2.window.html: Added. * LayoutTests/http/wpt/loading/early-hints/preload-main-frame-only.h2.window-expected.txt: Added. * LayoutTests/http/wpt/loading/early-hints/preload-cross-site.h2.window.js: Added; a preload parked during one site's navigation is not served to a fetch from another site. (openWindow): (messageFrom): (messageFrom.return.new.Promise): * LayoutTests/http/wpt/loading/early-hints/preload-cross-site.h2.window.html: Added. * LayoutTests/http/wpt/loading/early-hints/preload-cross-site.h2.window-expected.txt: Added. * LayoutTests/http/wpt/loading/early-hints/resources/preload-loader.h2.py: Added; sends a 103 preload and gives it a head start before the final response. (_preload_path): (handle_headers): (main): * LayoutTests/http/wpt/loading/early-hints/resources/preload-test.html: Added; shared page that consumes the hinted resource and reports back to the runner. (waitUntilFetched): * LayoutTests/http/wpt/loading/early-hints/resources/status.py: Added; non-blocking check for whether a recording endpoint was fetched. (_stash_dir): (main): * LayoutTests/http/wpt/loading/early-hints/resources/redirect.py: Added. (_stash_dir): (main): * LayoutTests/http/wpt/loading/early-hints/resources/recorded-script.py: Added. (_stash_dir): (main): * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-no-store.h2.window.js: Added. * LayoutTests/http/tests/ipc/ipc-fetch-task-message-crash.html: * LayoutTests/imported/w3c/web-platform-tests/loading/early-hints/preload-in-flight-when-consumed.h2.window-expected.txt:
|
EWS run on current version of this PR (hash 00e84c2) Details |
|
I implemented 103 This is a pretty big patch so it may take a while to understand exactly how this works but let's also tag some other folks here. cc @achristensen07 @youennf |
|
Thanks for looking in to this. We want to eventually support 103 preloads but I think it requires a good amount of work, and we haven't had a chance to work on it recently. Regarding this patch, here are some initial thoughts from a quick look at it. First, the priority here has to make sure the optimization is correct and doesn't actually regress performance (e.g. by causing us to make duplicate requests). For instance:
For (1): Unless I'm missing something, I don't think this patch consults the disk cache before sending out the preload request, which is a blocker. For (2): I suspect something may be wrong here but I haven't fully worked out--the part where For (3), it seems like some of this machinery is built out, but there are some cases where we can end up with a duplicate request. For instance, it looks like the 103 preload can send out a request for a subresource and then soon after (4) is what concerns me the most. Right now, the ResourceRequest for subresources is built out in WebProcess (mainly in Here are some mismatches that I can see that could have bad consequences:
Other issues that I can see:
So stepping back, I think the cleanest way to implement this might be something like:
It would also be good to get input from @achristensen07 and @youennf since they have dealt with the network stack more than me. |
|
Thank you so much for the feedback! I 100% agree that the goal here is to improve performance, not regress it. The cache bypass is a bug, & putting the resource in the right partition and matching in-flight requests should just work. I agree the first step in breaking this PR up to something that can work is to refactor the request creation from WebProcess into something that can be called from Network process. I'll get on that and send for y'all to review. A couple of points worthwhile getting agreement on:
|
|
The first refactoring bits are at #74672 |
🛠 ios-sim
🧪 wpe-wk2
00e84c2
00e84c2