-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Flutter Driver crashing when main has async operations #41029
Comments
Also getting this issue |
Same issue here...my current workaround is to add some //...
setUpAll(() async {
driver = await FlutterDriver.connect();
await sleep(Duration(seconds: 10));
// more setup...
} |
Same here! |
Since the call to await in main defers the creation of the app, the flutter driver starts up immediately and starts running tests. Problem is the app may not be fully initialized since the awaited call could still be in flight. That's why adding the delay before running your tests fixes the problem. Flutter should not start the tests until runApp is actually called. |
To fix this, the driver bindings could be updated to send a handshake single to the command line test. Then FlutterDriver.connect could be updated to wait for this signal before beginning DriverBinding: https://github.com/flutter/flutter/blob/master/packages/flutter_driver/lib/src/extension/extension.dart#L45 |
Sometimes I got this also |
@jonahwilliams can you give more instructions on how to update |
connect would need to wait for a firstFrame event or similar event from when the Widget tree is attached. I'm not quite sure what the exact approach would be |
I can't seem to get mine working - even putting the sleep i get the same error:
I tried the enableFlutterDriverExtension in main, but that didn't do anything; furthermore, this actually stopped it working on my teammate's machine! |
I also encountered this and tried to avoid hardcoded waiting times. I create a Gist (https://gist.github.com/Boehrsi/93c26371431367a639476a3a860ead60) which works well for me. Feel free to give it a try, hopefully it helps you too. |
I'm currently looking into this as well because it affects internal clients. (b/147455985) |
This has been fixed with the above two PRs, you should be able to call |
@jiahaog Flutter 1.17.5 not working is your fix on the stable branch? |
I don't think so, you'll have to wait a bit for it to hit stable 🙂 |
I'm facing this issue with the newly released integration_test package as well. Adding |
Me too. integration_test.dart: Future main() => integrationDriver();` app.dart: Future main() async { setupLocator(); runApp(MyApp()); app_test.dart: //import 'package:flutter_test/flutter_test.dart'; import 'workaround.dart'; void main() { print('group');
}); Widget buildTestableWidget(Widget widget) { pubspec.yaml: flutter doctor -v: [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [✓] Android Studio (version 3.5) [✓] VS Code (version 1.51.1) [✓] Connected device (1 available) • No issues found!` command line: console output: #0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1404:5) |
I/flutter ( 5443): Observatory listening on http://127.0.0.1:38955/uy7RO1jCdyE=/ VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:39733/uy7RO1jCdyE=/ |
Guys, I solved this changing 'package:test/test.dart' to flutter_test.dart |
I am still having this issue on the most recent dev build. My app.main method has several async tasks and the test starts while there is still "Starting Test..." on the device screen. If I add a manual wait I can avoid the issue but that feels very wrong. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Internal: b/147455985
My app has a few async operations that are initialized in
main()
. This works fine in my actual application. However, when attempting to run integration tests using Flutter Driver, the tests fail with the following error:From what I can tell, Flutter Driver doesn't let the app fully initialize before running the tests. If I remove the async operation, things run as expected.
Steps to Reproduce
I've created a minimal reproduction in this repo: https://github.com/jamesdixon/hive_flutter_driver_issue
flutter drive --target=test_driver/run_app.dart
Logs
The log output was quite long so I pasted it into a gist here: https://gist.github.com/jamesdixon/0b4d0895f6707bdaba439b158eb1110c
The text was updated successfully, but these errors were encountered: