Skip to content
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

Comparing screenshots on Linux and MacOS #359

Open
pettero opened this issue Mar 5, 2025 · 4 comments
Open

Comparing screenshots on Linux and MacOS #359

pettero opened this issue Mar 5, 2025 · 4 comments

Comments

@pettero
Copy link
Contributor

pettero commented Mar 5, 2025

Our developers have are running Macs and the CI is running on Linux. When generating screenshots the images are different.

The difference however is not that big...

For instance we have an input field that looks like this:

Image

Above the blue line in the bottom the emulator is adding a blueish line and that one differs between the mac and linux:

Image Image

How ever the "distance" between the colors is quite small (using Pythagoras)

sqrt((163-162)^2+(185-184)^2+(203-203)^2)=sqrt(2)

Would it be a good idea to complement the tolerance with a distance configuration to allow colors that are very similar to be treated as the same and keep the tolerance set to 0?

Feels like the change should be quite easy to make -

I can help out if it's a good idea.

@tdrhq
Copy link

tdrhq commented Mar 5, 2025

Btw, it turns out that it's faster and easier if the screenshots are always generated on CI, that way you always get identical screenshots and you don't have to do any image processing in your CI job which is quite expensive.

You could either write a script generate the generate the screenshots on CI automatically which is commonly done, or you could consider a tool like https://screenshotbot.io (which also solves the issue of image storage). We have a gradle plugin that integrates with Shot.

@pettero
Copy link
Contributor Author

pettero commented Mar 5, 2025

Currently we doing as you suggested but the CI takes a long time to run all the tests and I would like to be able to run all the tests locally to see that they are passing before I go to the next task at hand.

Looks like Paparazzi implemented a similar approach in their lib recently:

Relax image comparisons with OffByTwo differ to work around cross-platform rendering issues

https://cashapp.github.io/paparazzi/changelog/#135-2024-11-06

@tdrhq
Copy link

tdrhq commented Mar 5, 2025

@pettero Screenshotbot does support running tests locally, even though the screenshots are not stored in Git/Git LFS: https://screenshotbot.io/documentation/developer-tools/local-run . So you can effectively get the best of both worlds.

@pettero
Copy link
Contributor Author

pettero commented Mar 6, 2025

We have a similar setup using firebase test lab.

A challenge for us is that it takes time to run the tests remotely and we also loose the possibility to debug the tests.

I think we are leaning towards trying to verify colors using Euclidean distance for now.

https://en.wikipedia.org/wiki/Color_difference#sRGB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants