-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Comparing pixels instead of bytes with GoldenFileComparator #38473
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
Conversation
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Thanks @gspencergoog ! I will fix the formatting. |
|
Yes, I think it's probably OK too. I suspect that something that was bit-identical before is also pixel-identical now. |
| import 'dart:io'; | ||
| import 'dart:math' as math; | ||
| import 'dart:typed_data'; | ||
| import 'dart:ui'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per style guide, this should have been imported with "show" or "as ui": https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#import-conventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(It is not clear to me how dart currently decides if you want the Image class from dart:ui or from package:image. I am surprised that this works as is...)

Description
This PR changes the implementation of the
GoldenFileComparators method of comparison. While in the past, comparisons have been done bit-by-bit, this replaces that construct with pixel-by-pixel comparison.See follow-up section below for further implications of this change in
package:flutter/flutter.This also adds the features of more feedback in describing why a comparison fails as well as providing output of images to illustrate the difference. When a pixel comparison fails due to a detected difference, the following files will be output in a failure directory located where the master golden image was specified for the given test.
Output files will follow the format:
testname_ImageType.png
Other Options to Consider for this Change
An allowable pixel difference for each channel that is being compared
A % of pixel difference overall that can be dismissed as trivial
Follow-up
Following this PR, the improved comparator will be implemented further in the
package:flutter/fluttergolden file tests to incorporate Skia Gold baselines established with #36103. The follow-up to this change will enable local, pre-submit and post-submit testing forpackage:flutter/flutteracross all platforms. 🎉Related Issues
Fixes #17260
Fixes #17258
also maybe #17259, #30036
Tests
Updated/Added:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?