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

False positive on images #98

Open
AdeZwart opened this issue Aug 27, 2019 · 18 comments
Open

False positive on images #98

AdeZwart opened this issue Aug 27, 2019 · 18 comments

Comments

@AdeZwart
Copy link

AdeZwart commented Aug 27, 2019

Often we see false positives on images used, for example:
element_0_1024x768 diff

To me it feels/looks like there's some compression on the baseline, which is not applied when comparing the screenshots.

@sebinsua
Copy link

sebinsua commented Sep 9, 2019

What applies the compression? I think it is Cypress#screenshot itself which saves the screenshot in png and this is meant to be lossless.

@cbrunnkvist
Copy link

I have exactly this issue too. My particular pixel diff lands at around 10% which is too high of a threshold to be used as a viable workaround...

I typically run the CI on linux hosts and development & "update snapshots" on MacOS, but they both use Electron to do so headlessly so I don't understand what could make any difference there. If it has something to do with compression, that would make more sense.

@cbrunnkvist
Copy link

I can confirm that it is failing on color - one large plain colored UI element in my example RGB #47BFBB in the reference snapshot but #40BFBC in the right-hand-side part of the diff. Maybe somewhere the image is processed/compressed twice or something. But it still feels random because the diff I get from the linux CI host is different from the diff I can reproduce on my Mac.

@jameshoward
Copy link

jameshoward commented Dec 18, 2019

I think it's a colour profile issue. On OSX I have changed mine to different settings and get different colours in the screenshots.

It could be that your snapshots were generated with one colour profile and then your run is creating (and comparing) screenshots in another. This happens for us between locally on OSX and CI.

I don't think there's a way to force the colour profile that Electron uses, only Chrome, so we are seeing differences between the two as well.

@smrr723
Copy link

smrr723 commented Jan 15, 2020

Screenshot 2020-01-15 at 16 26 27
Screenshot 2020-01-15 at 16 27 23
Screenshot 2020-01-15 at 16 33 18
Screenshot 2020-01-15 at 16 33 28

I too am getting false positives. In the images above, I've zoomed in to show there is actually a slight pixel difference in some of the lettering on my page. It's not limited to text only, though. Other elements on the page are showing diffs without code changes.

I'm running this in a Bitbucket pipeline after generating images locally - both the pipeline and local installations are running the same (latest) version of Cypress & Electron. Are we any closer to an answer on what is causing this?

@smrr723
Copy link

smrr723 commented Jan 16, 2020

I think my issue above can be disregarded - it's a separate issue. On closer inspection, it looks like it's CSS / Operating System related, i.e the scrollbar is rounded in one image and square in the other, which I think is caused by my Mac.

Edit: my workaround for, for anyone else who encounters it, was to use docker both locally when creating my screenshots and in my pipeline (bitbucket), and used the same docker image on both. I followed the docker setup in the cypress docs:-

@0xIslamTaha
Copy link

I have the same issue and as a workaround, I manage to use a docker image to generate the base screenshots and use the same docker fie with my CI to do the visual testing

@billsaysthis
Copy link

We're experiencing a similar issue. We do use Docker images (running the tests on AWS). Out issue is that text is showing in slightly different positions (letters are a few pixels to the right or left compared to the baseline images). There are no changes to the files being tested, that is no CSS or HTML changes. This only happens on some runs of some tests but enough to block us from letting the tests act as blockers for allowing a PR to be merged.

An example image is attached.
377472726TabbedMenu+--+TabbedMenu diff

@mcintyret
Copy link

Could someone who has come up with a workaround kindly post more details of their approach? Would really appreciate it!

@mcintyret
Copy link

Actually I may have found one - adding ELECTRON_EXTRA_LAUNCH_ARGS=--disable-color-correct-rendering as an environment variable both locally and in CI seems to fix it (diff % went from ~25% to 0.1% for my case)

@acotapr
Copy link

acotapr commented Aug 16, 2021

Actually I may have found one - adding ELECTRON_EXTRA_LAUNCH_ARGS=--disable-color-correct-rendering as an environment variable both locally and in CI seems to fix it (diff % went from ~25% to 0.1% for my case)

Hi, we have the exact issue, @mcintyret tried your suggestion setting this flag but the new images are the same, nothing changes. How do you set the env var maybe I'm doing something wrong...

Edit:
I think I know why it wasn't working, we were using the chrome browser, I changed it to electron and then worked for colors but still getting the fonts issues

@MatiasArriola
Copy link

Same happening here. When I run the snapshots in CI, there is a difference in the colors. I am using electron, and tried the ELECTRON_EXTRA_LAUNCH_ARGS=--disable-color-correct-rendering env variable without success.
I get a 30% difference on some images, so I cannot workaround it by changing the threshold.

@0xIslamTaha
Copy link

@MatiasArriola
I had the same issue and I managed to solve it by running the test cases in docker containers in my local machine and in my CI machine too.

@SunStupic
Copy link

Same issue here, trying to use docker now.

@0xIslamTaha
Copy link

@sebinsua
I encourage u to use the orchestrator as a runner in your local machine or your CICD
https://github.com/0xIslamTaha/orchestrator

@archfz
Copy link

archfz commented Mar 7, 2022

@tomgazitbc
Copy link

Seemed that the following code fixes the color difference issue, notice that launchOptions has to be returned:

setupNodeEvents(on, config) {
            addMatchImageSnapshotPlugin(on, config);
            // force color profile
            on('before:browser:launch', (browser = null, launchOptions) => {
                if (browser.family === 'chromium' && browser.name === 'chrome') {
                    launchOptions.args.push('--force-color-profile=srgb'); // Works only in chrome
                    return launchOptions;
                }
            });
            return config;
        }

@MrCoder
Copy link

MrCoder commented Jun 9, 2023

I had to change my OS color profile to sRGB so the captured screenshot match the screenshot take in Github actions.
Screenshot 2023-06-09 at 9 54 46 pm

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