Repository navigation
flutter_goldens generate different files everytime #92590
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwill affect goldensChanges to golden filesChanges to golden files
Description
Hello, after migrating to flutter 2.5.0 our goldens failed as we noticed that there was a change in the shadows. We then had to recreate all of our goldens. After runing the tests with the new goldens, we still received a 0.0% diff in one of our screens.
Looking further it seems that for that particular widget the shadows are created differently each time, so a test can pass on one run and fail on the other, it's being totally random so far.
We extracted the code causing the issue and created a test repo.
Steps to Reproduce
- With flutter 2.5.x Execute
flutter teston the provided example repo, see how some test will fail - Execute
flutter test --update-goldensto create a fresh set of images - Execute
flutter testagain, and see how some test will still fail
Findings
- We have a function called
setupSizeto setup the size of the golden image. If we remove it's contents, the issue is fixed. - We have this code
Scaffold(
body: Stack(
children: [
// other children removed for demo
Positioned(
top: _defaultFloatingTopPosition - _offset,
right: 0,
left: 0,
child: IgnorePointer(....
)
)if we remove the Stack(children[Positioned( the issue is fixed.
Scaffold(
body: IgnorePointer(...Expected results:
Golden tests should not fail after updating images
Actual results:
Golden tests fail randomly
Code sample
Logs
flutter test
00:05 +4 -2: Home golden tests group2 Test7
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown while running async test code:
Golden "goldens/Test7.png": Pixel test failed, 0.00% diff detected.
Failure feedback can be found at /Users/diego/workspaces/goldendemo/test/failures
When the exception was thrown, this was the stack:
#0 LocalFileComparator.compare (package:flutter_test/src/_goldens_io.dart:101:7)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
Analyzing goldendemo...
No issues found! (ran in 1.1s)
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-MX)
• Flutter version 2.5.3 at /Users/diego/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (12 days ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/diego/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.61.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
[✓] Connected device (2 available)
• iPhone 13 Pro (mobile) • 4E63E183-DACE-4D21-A433-55DDA5A59F7E • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.54
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwill affect goldensChanges to golden filesChanges to golden files
Activity
[-]After flutter 2.5.0+ goldens create different each time[/-][+]After flutter 2.5.0+ goldens generate differently each time[/+]maheshj01 commentedon Oct 28, 2021
Hi @diegog-sf, Thanks for filing the issue. I can reproduce the issue on the latest stable and the master channel the updated goldens tests are failing. And the tests are failing randomly each time the goldens are updated.
flutter doctor -v
logs(master)
[-]After flutter 2.5.0+ goldens generate differently each time[/-][+]flutter_goldens generate different files everytime [/+]mattsolle commentedon Nov 12, 2021
Is this an antialiasing change? Stepping from 2.2.X to 2.5.X specifically is causing the issue to happen.
diegog-sf commentedon Nov 19, 2021
Hello, I found something interesting.
from the example provided, if I do as below, the problem gets fixed.
top: (_defaultFloatingTopPosition - _offset). roundToDouble(),Could the problem be because floating points aren’t determinant?
diegog-sf commentedon Dec 9, 2021
I just upgraded to
2.8.0I'm now having issues with this simple widget.
It is reproducible in the example project provided
diegog-sf commentedon Dec 9, 2021
should we be using
debugDisableShadowsand override the elevation ourselves? also the documentation of the variable seems wrongShouldn't it be:
but all tests on flutter do set it to false at the beginning