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(image-elements): remove resourceSize property #11733

Merged
merged 7 commits into from
Dec 7, 2020

Conversation

adrianaixba
Copy link
Collaborator

Remove resourceSize property, and depend on the image's network property instead.

Third item of #11642

@google-cla google-cla bot added the cla: yes label Dec 1, 2020
// HOWEVER, there are some cases where an image is compressed again over the network and transfer size
// is smaller (see https://github.com/GoogleChrome/lighthouse/pull/4968).
// Use the min of the two numbers to be safe.
const {resourceSize = 0, transferSize = 0} = networkRecord;
Copy link
Collaborator

@connorjclark connorjclark Dec 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickhulce this is still of concern ya?

I'd expect this test to fail in this PR (but it isn't).. https://github.com/GoogleChrome/lighthouse/pull/4968/files#diff-b15e1d5e110701eeaa3cf353d4108a5e61e699ae3afbcdb272c7816b978784f1R137 (although it has since been modified 5674d61#diff-b15e1d5e110701eeaa3cf353d4108a5e61e699ae3afbcdb272c7816b978784f1 ). Seems this case was missed when that test was refactored.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we should still account for it in the optimization cases Math.min(transferSize, resourceSize) is mostly what we want.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, one question about how artifacts.json was updated

@@ -16,7 +16,6 @@ const FontSize = require('./seo/font-size.js');

/* global window, getElementsInDocument, Image, getNodeDetails, ShadowRoot */


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes like this make me unreasonably happy.

"src": "http://localhost:10200/dobetterweb/lighthouse-480x318.jpg",
"displayedWidth": 480,
"displayedHeight": 57,
"src": "http://localhost:59523/dobetterweb/lighthouse-480x318.jpg?iar1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, how did the port change? did you use yarn update:sample-artifacts ImageElements to update this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i did use that 👀

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's b/c of this line https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/scripts/update-report-fixtures.js#L22 . I expected it to use the same port as the static server (10200). it being random is not good (code churn, if a line changes in a commit it should be because it really changed, not because there's a random number)

Altho this script has been like this since it was introduced 3 years ago #4793 ...

these are all the ports I found in artifacts.json

localhost:10200
localhost:50114
localhost:53133
localhost:54759
localhost:54819
localhost:9876

Eh, I'll file a bug but since this has existed forever this PR doesn't have to worry about it.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@devtools-bot devtools-bot merged commit c051eeb into master Dec 7, 2020
@devtools-bot devtools-bot deleted the remove-resource-size branch December 7, 2020 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants