pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.78k stars 580 forks source link

Possible Apple Silicon vs x86 snapshot issue solution? #711

Closed dangwu closed 1 year ago

dangwu commented 1 year ago

I might be wrong, so take this with a grain of salt, but in my project, the diff image (diffed via kCGBlendModeDifference) between an Apple Silicon snapshot and an x86 snapshot is seemingly always just an image containing all gray squares with a scattering of black pixels. The value of every pixel in the image is RGB:126-129 and A:255 or pure black RGBA(0, 0, 0, 255).

Couldn't the snapshot comparison check if the diff contains only these colors, and consider it a success if so? This would be more reliable than the existing "perceived difference/threshold" solution. It would probably be super slow to check every pixel, so maybe checking the average color of the image could work?

Example diff: Diffed