Skip to content

Flutter Driver crashing when main has async operations #41029

@jamesdixon

Description

@jamesdixon

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:

Result (on Emulators):
DriverError: Error in Flutter application: Uncaught extension error while executing tap: 'package:flutter_driver/src/extension/extension.dart': Failed assertion: line 193 pos 14: 'WidgetsBinding.instance.isRootWidgetAttached || !command.requiresRootWidgetAttached': No root widget is attached; have you remembered to call runApp()?

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

  1. Clone the repo
  2. Run 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

No issues found! (ran in 2.3s)
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.5 18F132, locale en-US)
    • Flutter version 1.9.1+hotfix.2 at /Users/jamesdixon/flutter
    • Framework revision 2d2a1ffec9 (2 weeks ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/jamesdixon/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/jamesdixon/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 38.2.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.38.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • iPhone 7 Plus • 790FC845-4FE6-49C0-8B15-09E3BE74FA3F • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)

Metadata

Metadata

Assignees

Labels

t: flutter driver"flutter driver", flutter_drive, or a driver testtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions