-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: fix resource size calculation of cached images #12612
core: fix resource size calculation of cached images #12612
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks very much @g-yonchev!
* @param {NetworkRequest} networkRecord | ||
* @return {number} | ||
*/ | ||
static getActualResourceSize(networkRecord) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about getTransferSizeOfResource
or getResourceSizeOnNetwork
or something?
actual resource size implies to me that we're trying to get the raw size of the resource, but that's not what we're looking for. the point of the transfer size workaround is for cases where the image is compressed over the network again (svg especially). we're just trying to find the size of the image as it was transferred over the network without the headers if we can help it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickhulce, good point. I renamed the func to getResourceSizeOnNetwork
.
* @return {number} | ||
*/ | ||
static getActualResourceSize(networkRecord) { | ||
// Resource size is almost always the right one to be using because of the below: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this into the jsdoc description for the function?
[networkRecord] | ||
); | ||
|
||
assert.equal(auditResult.items.length, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert that we're getting the wasted bytes correct too?
}; | ||
|
||
return UnusedImages.audit_(artifacts, [networkRecord], context).then(auditResult => { | ||
assert.equal(auditResult.items.length, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert that we're getting the wasted bytes correct too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks very much @g-yonchev!
@patrickhulce Just noticed that this PR didn't make it into 8.1.0. Are there any other criteria to be met for this PR to be merged? |
oh shoot, sorry @g-yonchev! No other criteria (other than fixing merge conflict now), just got forgotten in the shuffle |
I will fix the merge conflict. |
@patrickhulce I resolved the merge conflicts. |
Summary
This PR fixes an issue with cached images behaviour
Related Issues/PRs
see #12465 (comment)