GoogleChromeLabs / squoosh

Make images smaller using best-in-class codecs, right in the browser.
https://squoosh.app
Apache License 2.0
21.76k stars 1.53k forks source link

PNG to WebP colourful artifacts in FF 91.0.2 #1145

Open Nooshu opened 3 years ago

Nooshu commented 3 years ago

Describe the bug Converting this PNG to WebP in latest FF (91.0.2) generates a whole bunch of colouful artifacts in the image. I've tested Chrome and it works fine.

To Reproduce Steps to reproduce the behavior:

Expected behavior Output image look similar to JPEG / AVIF versions.

Version:

Is your issue related to the quality of image compression? Yes

Original image after-score-result

Output image from Squoosh (WebP not supported by GH, screenshot below)

Screenshot 2021-09-07 at 05 42 06

Additional context, screenshots, screencasts

PNG to WebP

Screenshot 2021-09-06 at 22 39 43

PNG to MozJPEG

Screenshot 2021-09-07 at 05 28 08

PNG to AVIF

Screenshot 2021-09-07 at 05 35 24
edent commented 3 years ago

Also occurs on Android Firefox 91.4.0 (Build #2015831131) Tried various levels of compression etc - all produce these weird artefacts.

jakearchibald commented 3 years ago

Huh, it doesn't happen for me on OSX, but it does happen on my Pixel 5.

Given that M1 Macs (which @Nooshu has) and the Pixel 5 are ARM-based, I wonder if that's the common element here.

surma commented 3 years ago

Saving the WebP with the artifacts to disk and opening it in Chrome also shows the artifacts, implying that the generated WebP is in fact broken (and not just FF’s built-in decoder).

This kinda implies that FF has an arm64 code gen bug in their Wasm engine. I’ll try and build a repro and report it to FF

rik commented 3 years ago

On my M1, I can confirm it reproduces on Firefox but not Chrome nor Safari.

jakearchibald commented 3 years ago

I see that the pinch zoom UI is broken on Firefox Android, so I'll go fix that. https://github.com/GoogleChromeLabs/squoosh/issues/1146

surma commented 3 years ago

On further inspection, the bug goes away if I disable Wasm SIMD in about:config, so it seems to be specifically about SIMD instructions on arm64.

surma commented 3 years ago

Built a reproduction case: https://sedate-entertaining-card.glitch.me/

This seems to be fixed in Firefox Nightly, so it’s a matter of waiting :)

jakearchibald commented 3 years ago

I realise it probably means adding a UA-sniff, but should we bypass SIMD in Firefox for a bit?

rik commented 3 years ago

I think it's already fixed in Firefox 92 which will be released later today. (I can only say "I think" because I could only test once on 92 before my Firefox Beta switched to 93)

surma commented 3 years ago

FF 93 ships today. If that fixes it, that’s good enough. If not, we might wanna ship a workaround.

Screen Shot 2021-09-07 at 13 15 14

(I’m also wondering if we should add some debug flags to Squoosh that force-enable/force-disable Wasm features.)

Krinkle commented 3 years ago

Was the upstream fix backported to 91ESR? Might be worth reporting to upstream still from that perspective (eg in case the fix was accidental or otherwise without knowledge of this glitch, thus perhaps not backported).

cadeyrn commented 3 years ago

It looks like https://bugzilla.mozilla.org/show_bug.cgi?id=1720650 (colored artifacts on ARM64 devices in connection with WASM/SIMD). If it has the same cause, then yes, it's fixed in Firefox ESR 91.1. Unfortunately I don't own such a device and can't verify.

jakearchibald commented 3 years ago

Good find @cadeyrn. I agree that's the same issue.