Skip to content
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

Merged

Conversation

g-yonchev
Copy link
Contributor

@g-yonchev g-yonchev commented Jun 3, 2021

Summary
This PR fixes an issue with cached images behaviour

Related Issues/PRs
see #12465 (comment)

@g-yonchev g-yonchev requested a review from a team as a code owner June 3, 2021 12:02
@g-yonchev g-yonchev requested review from connorjclark and removed request for a team June 3, 2021 12:02
@google-cla
Copy link

google-cla bot commented Jun 3, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Jun 3, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@g-yonchev g-yonchev changed the title Fix behaviour cached images (core): Fix behaviour cached images Jun 3, 2021
@google-cla
Copy link

google-cla bot commented Jun 3, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@g-yonchev g-yonchev changed the title (core): Fix behaviour cached images core: Fix behaviour cached images Jun 3, 2021
@google-cla
Copy link

google-cla bot commented Jun 3, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Jun 3, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@g-yonchev g-yonchev marked this pull request as ready for review June 3, 2021 16:06
@g-yonchev
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 3, 2021
@g-yonchev g-yonchev changed the title core: Fix behaviour cached images core: fix behaviour cached images Jun 3, 2021
Copy link
Collaborator

@patrickhulce patrickhulce left a 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) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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:
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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?

Copy link
Collaborator

@patrickhulce patrickhulce left a 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!

@connorjclark connorjclark changed the title core: fix behaviour cached images core: fix resource size calculation of cached images Jun 16, 2021
@Janpot
Copy link
Contributor

Janpot commented Jul 14, 2021

@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?

@patrickhulce
Copy link
Collaborator

oh shoot, sorry @g-yonchev! No other criteria (other than fixing merge conflict now), just got forgotten in the shuffle

@g-yonchev
Copy link
Contributor Author

I will fix the merge conflict.

@g-yonchev
Copy link
Contributor Author

@patrickhulce I resolved the merge conflicts.
There was also a test failing which I fixed with the commit b96e454

@patrickhulce patrickhulce merged commit 36454ee into GoogleChrome:master Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants