Can I ask which browser you're using?

I was unable to reproduce the exact same issue you described here on Firefox 128 on Linux... however, you're definitely onto something!

It's a combination of two subtle issues:

1) A known bug in the jpegli library. As you suspected, XYB mode combined with chroma subsampling (like the old 4:2:0 default) can cause the exact "downscaled" look you saw. [0]

2) A sizing bug in my decoder pipeline. I was mistakenly using an image's internal codedWidth instead of its final displayWidth. For some WebP/AVIF files, this created a smaller image on a larger canvas, which magnified the XYB bug.

I've just pushed a fix that addresses both issues. I've also updated the defaults to what I believe is a much better starting point: Quality 80, XYB, and 4:4:4 subsampling. This combination avoids the bug while still leveraging the best perceptual model, so it should prevent those surprising quality drops.

Thanks again for the incredibly detailed report-it was super helpful!

There's an unbelievable amount of edge cases with all of these different image formats. It's been a great learning experience for sure!

[0] https://github.com/google/jpegli/issues/122