Commit Graph

6 Commits

Author SHA1 Message Date
Andrey Lushnikov
6d82460a02
feat: implement a new image comparison function (#19166)
This patch implements a new image comparison function, codenamed
"ssim-cie94". The goal of the new comparison function is to cancel out
browser non-determenistic rendering.

To use the new comparison function:

```ts
await expect(page).toHaveScreenshot({
  comparator: 'ssim-cie94',
});
```

As of Nov 30, 2022, we identified the following sources of
non-determenistic rendering for Chromium:
- Anti-aliasing for certain shapes might be different due to the
  way skia rasterizes certain shapes.
- Color blending might be different on `x86` and `aarch64`
architectures.

The new function employs a few heuristics to fight these
differences.

Consider two non-equal image pixels `(r1, g1, b1)` and `(r2, g2, b2)`:
1. If the [CIE94] metric is less then 1.0, then we consider these pixels
   **EQUAL**. (The value `1.0` is the [just-noticeable difference] for
   [CIE94].). Otherwise, proceed to next step.
1. If all the 8 neighbors of the first pixel match its color, or
   if the 8 neighbors of the second pixel match its color, then these
   pixels are **DIFFERENT**. (In case of anti-aliasing, some of the
   direct neighbors have to be blended up or down.) Otherwise, proceed
   to next step.
1. If SSIM in some locality around the different pixels is more than
   0.99, then consider this pixels to be **EQUAL**. Otherwise, mark them
   as **DIFFERENT**. (Local SSIM for anti-aliased pixels turns out to be
   very close to 1.0).

[CIE94]: https://en.wikipedia.org/wiki/Color_difference#CIE94
[just-noticeable difference]:
https://en.wikipedia.org/wiki/Just-noticeable_difference
2022-12-02 15:22:05 -08:00
Pavel Feldman
6adf94a8cd
chore: lang hint for GitHub 2021-12-13 04:05:17 -08:00
Andrey Lushnikov
fd3ec50cf6
devops: switch to LF line-endings in Git for text files (#10292)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2021-11-15 17:48:49 +01:00
Pavel Feldman
e003aa5cee chore: remove the .gitattributes entries for md/yml 2021-01-20 15:43:20 -08:00
Dmitry Gozman
4ff7e1a419
chore: cleanup our build system (#4903)
- Consolidate our build and watch to a single build.js file.
- Update contributing docs.
- Remove unused scripts and package.json script entries.
2021-01-06 12:41:17 -08:00
Joel Einbinder
184b25ff7b
chore: windows bots via github actions (#678)
Mac will come in a follow up!

As a drive-by, removed npm build everywhere, because npm install already runs build.
2020-01-28 18:04:51 -08:00