New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 882344 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

High priority ResourceRequest's seem to be exempt from low-priority experiments

Project Member Reported by domfarolino@gmail.com, Sep 10

Issue description

ResourceFetcher::ComputeLoadPriority does the following:
 - Computes a reasonable priority for a request, called `priority`, given some information
 - Returns the max of:
   - ResourceRequest's original priority (lowest, unless manually set elsewhere)
   - ...and whatever any currently-running experiments say the generated `priority` should be, after applying the experiment's parameters (if necessary)

A (the only?) Blink loading experiment that currently gets triggered via ResourceFetcher::ComputeLoadPriority, is the Low Priority Iframes experiment (+tbansal@). From what I can tell, this experiment smooshes all request priorities to either kLow or kLowest if the request was made from a child frame (and the experiment is enabled of course).

As a result of the current architecture, ResourceRequests that have their priority set to things like ~kHigh before reaching ResourceFetcher::ComputeLoadPriority, like module scripts [1], never actually get affected by experiments that down-prioritize eligible requests.

I think it is unlikely that we want all module scripts, and potentially future requests that have their priority manually set for any reason, to be exempt from low-priority experiments, but I'm not sure? (If this was intended, feel free to close this!). This "issue" can be seen in practice by visiting [2] and looking at the network pane in the DevTools. Imagine if an advertiser wanted to get around the low-priority iframes experiment. They could just fetch their scripts as "type=module", and it seems that the script will be the only high-priority resource from the frame, thus beating the low-priority-iframes experiment.

Another issue with this current architecture is very related to 872776. Imagine we make a low-priority request that goes through a Service Worker's FetchEvent (that uses fetch() to request the resource). Blink will preserve the priority from the original request, but in ComputeLoadPriority, since we're fetching from the fetch request context, we'll "upgrade" the priority to kHigh. Instead, it would be nice if we could skip "ComputeLoadPriority" altogether here since we have a preserved priority we'd like to use, and the apply the experiment separately for the last say.

I propose we change the current arch such that the ComputeLoadPriority-logic and the applying-experiment-to-priority logic are decoupled. We could skip calling ComputeLoadPriority for ResourceRequest's that have already had their priority manually set elsewhere (some flag?), and still _always_ run the experiment logic, to give any active experiments the final say in priority. Thoughts?


[1]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/loader/modulescript/module_script_loader.cc?sq=package:chromium&g=0&l=186

[2]: https://swift-basil.glitch.me/
 
I think the max() part in the ComputeLoadPriority part can be changed (maybe in addition to other refactorings) as doing max() there just feels confusing (at least to me). All we want to make sure is (afaik) we don't lower the priority for sync requests, and also do not lower the image request's priorities that were initially high (in the code path of UpdateAllImageResourcePriorities).

Comment 2 by y...@yoav.ws, Sep 12

Yeah, maybe the right way to go is to add another flag indicating that a priority should not be readjusted (e.g. images that were upgraded and then moved out of viewport, fetch from SW where we want to preserve former priority), and avoid the adjustment just there.
Ok that all makes sense. Since at least some stuff will be jostling around a bit, I’ll add some simple priority-based layout tests as well so we can make sure there are no unexpected regressions (especially wrt sync requests as kinuko@ mentioned).
Status: Available (was: Untriaged)
Status: Assigned (was: Available)
Project Member

Comment 6 by bugdroid1@chromium.org, Oct 31

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1252ba164ac5407756d1cab3d6d598f27563b88c

commit 1252ba164ac5407756d1cab3d6d598f27563b88c
Author: Dominic Farolino <domfarolino@gmail.com>
Date: Wed Oct 31 07:30:46 2018

Add initial resource load priority layout tests

R=kinuko@chromium.org, kouhei@chromium.org, yhirano@chromium.org, yoav@yoav.ws

Bug: 882344
Change-Id: I42e264f9fc1591129091aa9f18b258a4e2313181
Reviewed-on: https://chromium-review.googlesource.com/c/1249400
Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604181}
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resource-load-priorities.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/async-script.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/common.js
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/defer-script.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/fetch.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/iframe.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/module-script.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/off-screen-image.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/parser-blocking-script.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-audio.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-fetch.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-font.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-image.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-script.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-style.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/preload/as-video.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/render-blocking-stylesheet.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/sync-xhr.html
[add] https://crrev.com/1252ba164ac5407756d1cab3d6d598f27563b88c/third_party/WebKit/LayoutTests/http/tests/priorities/resources/xhr.html

Sign in to add a comment