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
AVIF images fail to render in Chrome Canary #3977
Comments
Thanks for reporting, I guess the Chrome team is either intentionally or inadvertently tightening up AVIF validation. The complete ComplianceWarden output suggests there is a single difference:
Taking a quick look at ...but testing against The next step is probably to see if this can be reproduced using |
I’m not sure what you mean. When I run Using ImageMagick via transparent-pixel.png.zip |
I opened an issue with Chromium: https://issues.chromium.org/issues/323735410. I converted the 1x1 transparent pixel PNG to AVIF via The I tried the same experiment with a 1x1 solid white pixel PNG: import { Buffer } from 'node:buffer'
import { writeFile } from 'node:fs/promises'
import sharp from 'sharp'
const whitePixelPngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAAaADAAQAAAABAAAAAQAAAADa6r/EAAAADElEQVQIHWP4//8/AAX+Av6fyi0TAAAAAElFTkSuQmCC'
const whitePixelPng = Buffer.from(whitePixelPngBase64, 'base64')
const avifImage = await sharp(whitePixelPng).avif().toBuffer()
writeFile('white-pixel-sharp.avif', avifImage) All the generated AVIF images, from Sharp and ImageMagick and |
Sorry, I meant
The ImageMagick example uses chroma subsampling (420) and still breaks in Chrome Canary, so this doesn't appear to be related to subsampling. The avifenc example differs in that it uses a monochrome colourspace (vs YCbCr), which might help narrow this down. @wantehchang Are you able to help investigate this? |
A fix has landed in Chrome Canary: https://issues.chromium.org/issues/323735410#comment8 It looks like they just rolled back the change that caused the breakage. I don’t know if they intend to try again, and if there are any issues to address on the Sharp/ |
Geoffrey: Thank you for reporting this bug. This is a bug in libavif only. (It validated itemID ordering in the wrong function.) Nothing needs to be addressed on the Sharp/libheif side. My colleague Vignesh (@vigneshvg) has fixed the bug in libavif and updated the libavif snapshot in Chrome Canary. |
Brilliant, thanks both. |
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?What are the steps to reproduce?
Save the following as
test.mjs
:Running this generates a 1x1 transparent pixel AVIF. Previewing it in Finder or in current stable Chrome (121.0.6167.139), it looks as expected. If I open it in Chrome Canary 123.0.6280.0, such as via a
file://
URL likefile:///Users/Geoffrey/Desktop/transparent-pixel.avif
as of this writing, I see this:Obviously this could be a bug in Chrome, but because of #2666 I thought perhaps this might be an issue with Sharp.
What is the expected behaviour?
It should render, like it does for stable Chrome.
Further steps:
writeFile('transparent-pixel.png', transparentPixelPng)
to the end of the above script and run it again, to generatetransparent-pixel.png
.avifenc transparent-pixel.png transparent-pixel-2.avif
transparent-pixel-2.avif
in Chrome Canary. For me it displays correctly, unlike the “broken image” result of the Sharp-generatedtransparent-pixel.avif
.Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
See above.
Please provide sample image(s) that help explain this problem
Here is the
transparent-pixel.avif
generated by Sharp:transparent-pixel.avif.zip
Running this file through https://gpac.github.io/ComplianceWarden-wasm/index.html shows that it contains a compliance error:
The text was updated successfully, but these errors were encountered: