From 6139b432fd40b311219c60392fc0086b70c4c261 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 7 Dec 2022 16:25:16 -0800 Subject: [PATCH] fix(ssim-cie94): increase SSIM window radius (#19343) While migrating Playwright tests from pixelmatch comparator to the ssim-cie94 comparator, we noticed a rendering artifact that happens on playwright screenshot tests on WebKit Linux. This PR adds a set of cropped-down examples and tunes the ssim-cie94 comparator to accept these rendering artifacts. --- .../playwright-core/src/image_tools/compare.ts | 2 +- .../webkit-rendering-artifacts/README.md | 2 ++ .../webkit-corner-pixel-actual.png | Bin 0 -> 309 bytes .../webkit-corner-pixel-expected.png | Bin 0 -> 307 bytes .../webkit-four-pixels-actual.png | Bin 0 -> 162 bytes .../webkit-four-pixels-expected.png | Bin 0 -> 156 bytes .../webkit-pixel-actual.png | Bin 0 -> 165 bytes .../webkit-pixel-expected.png | Bin 0 -> 156 bytes 8 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/README.md create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-actual.png create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-expected.png create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-actual.png create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-expected.png create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-pixel-actual.png create mode 100644 tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-pixel-expected.png diff --git a/packages/playwright-core/src/image_tools/compare.ts b/packages/playwright-core/src/image_tools/compare.ts index 2748d5a91c..4b79d36eb0 100644 --- a/packages/playwright-core/src/image_tools/compare.ts +++ b/packages/playwright-core/src/image_tools/compare.ts @@ -18,7 +18,7 @@ import { blendWithWhite, colorDeltaE94, rgb2gray } from './colorUtils'; import { ImageChannel } from './imageChannel'; import { ssim, FastStats } from './stats'; -const SSIM_WINDOW_RADIUS = 5; +const SSIM_WINDOW_RADIUS = 15; const VARIANCE_WINDOW_RADIUS = 1; function drawPixel(width: number, data: Buffer, x: number, y: number, r: number, g: number, b: number) { diff --git a/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/README.md b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/README.md new file mode 100644 index 0000000000..864638a9b1 --- /dev/null +++ b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/README.md @@ -0,0 +1,2 @@ +A set of examples with rendering artifacts that happen when running Playwright +screenshot tests on WebKit linux. diff --git a/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-actual.png b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-actual.png new file mode 100644 index 0000000000000000000000000000000000000000..eae4aeb66e89ec52dabb17b50612b7104acc0c08 GIT binary patch literal 309 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx|@C#^NA%C&rs6b?Si}&H|6fVg?3o zVGw3ym^DWNC>S2#6XH5y!i1G8SN=b9X8rp0Vq#)IVIw1>-Me?2nwrj^KVL~n>DaMj zdU|>m78bs~zH{cxX>V^oaNxl44OIku3fu!+O%m}T3R_dIi8-Ln>KCg z?(SZ5v!fPhR=KB(V@SoEx0iPEH7H0hC%9;LRXl9G{@Z@JL^!*&`sDr2;-6Go7la&g zQ=Qc#py;%3vWat^#-v3Wx>{{Jtfu8kG?|4>4}22mK0(gzTf;|N!x<4p{L(WLrHa=$ z#MbY;cRjLAV@=)Ra{{#t9R2G5fB$i6;iyz8@p~5|axXu6zAn%S44$rjF6*2UngH~b Bbu|D0 literal 0 HcmV?d00001 diff --git a/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-expected.png b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-corner-pixel-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..ee469a947b3d56178039d9b160b06f56b5dbc34b GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx|@C#^NA%C&rs6b?Si}&H|6fVg?3o zVGw3ym^DWNC>S2#6XLpZ<;wqO&a7X*UQA33C}w12w0rk%Q&ZFV^XDrmDIGg@OixeG z!otGW*LTjGIqmK32M!!Ke*F0A)vHgRK7H`u!L@7GPMbDOOG|6Qgb6u0Ii8-Ln>KCg z?(R;%%U1<7uGG`TF{EP7+e_wr4F)320Zu-g3%{5BFa9K`&D_TMvigIN?a59d7X73X z8i9+RSaa$wnxUjP>55`<$N8l(2L+}COtF>-l_AKnE~*y85}Sb4q9e0K}+t AW&i*H literal 0 HcmV?d00001 diff --git a/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-actual.png b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-actual.png new file mode 100644 index 0000000000000000000000000000000000000000..08d2831a89b2271c5e2f9af3be07f2c6caf12883 GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^xNi%$guQuU3QmYkgI4HTkIEX3)IBm>FVdQ&MBb@ E0D&_u+5i9m literal 0 HcmV?d00001 diff --git a/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-expected.png b/tests/image_tools/fixtures/should-match/webkit-rendering-artifacts/webkit-four-pixels-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..2c2af04401d6659179d141f25706480a364e7b47 GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^xdtsC-1B;~EEs}>z`;O-kIC)mOJzQWXPs@I9=dtsC-1B;~EEs