Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
TestImageOperationsGolden: arm64, ppc64le, s390x generate slightly different PNGs due to "fused multiply and add" (FMA) instruction #6387
On arm64, ppc64el (ppc64le) and s390x platforms, TestImageOperationsGolden reveals that Hugo (or github.com/disintegration/gift or an underlying library it uses) generates image with different file sizes, as seen on Debian auto-builders and Ubuntu snap builders, and reproducible on e.g. Debian s390x porterbox zelenka.debian.org:
The files that differ on s390x are as follows:
Further investigation is needed and pending.
What version of Hugo are you using (
Thank you for the idea regarding potential difference in PNG header, which prompted me to experiment with various PNG comparison tools such as pngmeta, pngcheck, etc., and eventually, perceptualdiff (http://pdiff.sourceforge.net/, https://github.com/myint/perceptualdiff). According to this tool, all images are visually identical except these four:
This is how the last image from above look like:
Feeling perplexed, I tried my luck by browsing https://github.com/disintegration/gift more carefully, and noticed the message "fix tests on arm64, ppc64le, s390x" beside colors_test.go, which led me to disintegration/gift#20 where Grigory (@disintegration) explained:
and to disintegration/gift@a999ff8 where Grigory solved with a new goldenEqual function:
which I guess could be adapted for Hugo to handle most of the golden images, maybe except some of the 8-bit colour images where tiny differences become visible differences due to dithering.
Aside: It seems golang.org/x/image/vector ran into the same issue two years ago, see https://groups.google.com/forum/#!topic/golang-dev/Sti0bl2xUXQ
Another aside: It appears that ppc64le and s390x have the same FMA implementation as they produce identical PNG images, whereas arm64's FMA results in slightly different results in 4 PNG images.