-
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(tsc): fix ImageUsage artifact type and gather bug #5113
Conversation
// Images within `picture` behave strangely and natural size information isn't accurate, | ||
// CSS images have no natural size information at all. | ||
// Try to get the actual size if we can. | ||
const elementPromise = (element.isPicture || element.isCss) && element.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.
this was the bug. element.networkRecord
was never defined at this point
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.
nice catch! good news is looks like this was introduced just 11 days ago so no one's bumped into it yet :) https://github.com/GoogleChrome/lighthouse/pull/5019/files#diff-a76f9d68fa433ad16daad08121c7411fR182
// Images within `picture` behave strangely and natural size information isn't accurate, | ||
// CSS images have no natural size information at all. | ||
// Try to get the actual size if we can. | ||
if (element.isPicture || element.isCss) { |
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.
should we maintain the original concern and only fetch when we can find the network record? fetchElementWithSize
is the expensive path
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.
should we maintain the original concern and only fetch when we can find the network record?
Only uses-responsive-images
seems to use naturalWidth
/naturalHeight
from css/<picture>
images, and it requires a networkRecord to work, so makes sense
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.
when we can find the network record?
...actually this conversation clearly shows that it should have been an optional property...
lol, hadn't looked at the blame yet :) Shows the danger of trying to do a |
sorry for the expanding scope, but this should properly reflect the |
@@ -55,11 +57,15 @@ class OffscreenImages extends ByteEfficiencyAudit { | |||
} | |||
|
|||
/** | |||
* @param {!Object} image |
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.
not sure how this slipped by :)
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.
wfm!
The type for the
ImageUsage
artifact accidentally left off the optional imagewidth
andheight
, which made using it in theimage-aspect-ratio
audit impossible before. Fixed the artifact and removed the@ts-nocheck
from the audit.In the process, uncovered a bug in the gatherer. At some point shifting types made the extra fetch of size information never run for css or
<picture>
images. As a result, thenaturalWidth
andnaturalHeight
was being left atNumber.MAX_VALUE
for those and so thewastedPercent
for those images was 100% in theuses-responsive-images
audit :)There was a clue in the smoke code coverage, but we hadn't noticed yet :)
Fixed the bug and added more specific expectations for that audit.