-
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
Bits per pixel calculation is not intrinsic-density-aware #12729
Comments
Similarly, this image: <img srcset="four-bits-per-pixel.jpg 100w" sizes="100vw" /> would pass when encountered in almost all viewports, because its intrinsic density will be 100w ÷ 100vw in CSS pixels (aka window.innerWidth). If my math is correct that means as long as the viewport is over 200px wide, this four-bits-per-pixel image will pass the audit. |
Thanks for filing @eeeps! Do you have a minimal example where Lighthouse is getting this wrong? You are correct that ordinary natural dimensions would be incorrect, but Lighthouse does not trust the natural dimensions in picture/srcset situations and instead creates a new image to measure the natural dimensions of the source URL
If you're not seeing this work as expected, a live example with expected/actual would be great :) |
Ah! I missed that code path. Should have tested before I filed, apologies. I'll make a small note that, when EXIF-based intrinsic image sizing becomes more widespread, even image resources that aren't embedded within |
The optimized images logic looks to see if images are less than two bits/pixel. But the pixels it's measuring (element.naturalWidth * element.naturalHeight) are the density-corrected intrinsic dimensions. So this image:
would pass the audit. But this one, embedding the same image resource (and therefore having the same number of bytes), would have 1/4 the total "pixels" as measured by the audit:
..and it would fail.
The text was updated successfully, but these errors were encountered: