Tried an approch for text case in pixelmatch#7552
Conversation
|
Thanks @Vaivaswat2244, nice approach! I have a few questions that might help us determine how to get this across the finish line.
|
|
yeah sure, the text() passing makes much more sense. I can implement that. |
|
hey, so I just noticed that the files which I added in the earlier commit aren't the one which are failing the tests on CI, but they are other files which were not touched. Now, I changed the files which were failing tests in CI, and tried the tests locally. The tests are now failing for different files in the typography and webgl cases. I guess there is a problem with my changes in the visualtest file. |
|
Just looking at the last failure in the test file: ...it looks like a few isolated pixels are off. I wonder if we can do something to augment pixelmatch and check if the difference exists just on a single pixel (so no surrounding pixels are also flagged) and then ignore those? |
|
Sure, I can try that |
|
Hey, @davepagurek, So I tried to customize pixelmatch for our needs. In order to avoid the isolated pixels and also some clusters which I saw ion some failed screenshots,
Now, the thing is that I have commited two variations of the approach, the earlier one was with less tolerant(failed the same cases as failing in CI), So, I needed a help with this, in one of the failed cases, Now this is a scenario which is getting failed in both the cases(less and more tolerant). |
|
Nice, the clustering idea is good and gives us some options for dealing with issues like this! I suspect if a shape is consistently 1px thick, then it could be the result of a shift due to environment differences. A way to check that might be to try to see if, for every pixel in the cluster, it has at most two neighbours? |
|
I have made some changes to this, so now additional to clustering logic our algo does the following
Using this and keeping the thresholds same as the more tolerable commit, the tests are now passing. So is there anything else I should change. |
davepagurek
left a comment
There was a problem hiding this comment.
Awesome, this is looking really promising, great work! I think the algorithm is in a spot where it's good to go. The last thing might be to add a comment somewhere explaining the general approach of the diff algorithm, similar to what you've described in comments to me here, and maybe additionally why it's necessary at all (because contributors running tests just on their own system might not realize that there will be differences on CI.)
| scale *= 2; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Can we take out the whitespace here?
| // Define significance thresholds | ||
| const MIN_CLUSTER_SIZE = 4; // Minimum pixels in a significant cluster | ||
| const MAX_TOTAL_DIFF_PIXELS = 40; // Maximum total different pixels | ||
| const MAX_LINE_SHIFT_PIXELS = 200; |
There was a problem hiding this comment.
First two are getting used in the check match function itself for final comparison.
Variation of these thresholds also causes variations in the tests results as well, like the Min_Cluster_Size if reduced from this makes our test less tolerable and can cause false CI fails like we saw in the isolated pixel case.
The line shift pixels is not needed. I'll remove that










Resolves #7496
Changes:
Modified the
checkMatchfunction invisualtest.jsto be more tolerant of slight text position shifts while still catching meaningful changes. Key changes:Added text detection using pixel pattern analysis:
Implemented shift tolerance for text regions:
shiftThresholdparameterScreenshots of the change:
PR Checklist
npm run lintpasses