Skip to content

Connect to VM timeout when doing integration tests #50898

Closed

Description

@tianhaoz95

Steps to Reproduce

  1. Run flutter drive --target=test_driver/app.dart.
  2. see the error on test startup:
VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
VMServiceFlutterDriver: It is taking an unusually long time to connect to the VM...
...

Expected results: the integration tests should start running in the emulator

Actual results: it keeps saying cannot connect to VM and finally timeout.

see this CI run: https://github.com/tianhaoz95/photochat/pull/17/checks?check_run_id=449361947#step:6:936

logs_157.zip

Activity

  1. jagsme commented on Feb 17, 2020

    @jagsme

    I am also facing a similar issue, but it is when you try to pause the build and run in parallel,

    as mentioned in here -#41583

    I am able to run the app on the devices and pause them as well, but unable to attach the driver to the URI

    this command
    flutter drive -d all --use-existing-app="$(cat foo)" --driver=test_driver/app_test.dart -v

  2. added
    a: tests"flutter test", flutter_test, or one of our tests
    t: flutter driver"flutter driver", flutter_drive, or a driver test
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Feb 17, 2020
  3. TahaTesser commented on Feb 17, 2020

    @TahaTesser
    Contributor

    Could be related #34196

  4. jagsme commented on Feb 17, 2020

    @jagsme

    the #34196 is not what I am facing, I am able to execute tests with flutter drive, the thing I am facing here is when we connect flutter driver to the URI as mentioned in here #41583

  5. removed
    a: tests"flutter test", flutter_test, or one of our tests
    on Feb 17, 2020
  6. jagsme commented on Feb 18, 2020

    @jagsme

    @TahaTesser
    the issue is fixed when we upgrade flutter version to Flutter 1.12.13+hotfix.8.

  7. tianhaoz95 commented on Feb 18, 2020

    @tianhaoz95
    Author

    UPDATE:
    It doesn't happen to all emulators. For example, pixel and pixel_xl are okay, but pixel_c has this issue.

    pixel_c repeatedly fail with this error.

  8. tianhaoz95 commented on Feb 21, 2020

    @tianhaoz95
    Author

    UPDATE:
    upgrading to 1.12.13+hotfix.8 didn't fix the issue. Please see https://github.com/tianhaoz95/photochat/runs/461236331?check_suite_focus=true for more logging details.

  9. HerrNiklasRaab commented on Feb 25, 2020

    @HerrNiklasRaab

    @tianhaoz95
    Upgrading to 1.12.13+hotfix.8 fixed it for me

  10. tianhaoz95 commented on Feb 25, 2020

    @tianhaoz95
    Author

    @HerrNiklasRaab can you add the channel you were on? I tried stable. Maybe dev should be better?

  11. HerrNiklasRaab commented on Feb 25, 2020

    @HerrNiklasRaab

    I was on stable to:

    [✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale de)
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    [✓] Android Studio (version 3.5)
    [✓] VS Code (version 1.42.1)
    [✓] Connected device (2 available)
    
    • No issues found!
    
  12. 20 remaining items

  13. Kiruel commented on Nov 23, 2022

    @Kiruel

    Got the same problem on flutter 3.3.8 on emulator iPhone 14 pro max.

  14. praxder commented on Dec 1, 2022

    @praxder

    Same issue here. Keeping us from being able to use integration tests since they can't be run consistently in CI/CD.

  15. bartekpacia commented on Dec 1, 2022

    @bartekpacia
    Member

    This was mostly fixed in #113969 by the awesome @jakubfijalkowski. Should be available in the next stable Flutter release.

  16. littleGnAl commented on Sep 28, 2023

    @littleGnAl
    Contributor

    I faced a similar issue on github runner when running the ios integration test by using the flutter test integration_test, it keeps failing, here is the failed run:
    https://github.com/AgoraIO-Extensions/iris_method_channel_flutter/actions/runs/6321185956/job/17164814096

    But if I specify the test file and the device flutter test integration_test/my_test_file.dart -d "iPhone 14 Pro Max" --verbose it finally succeeded, although it still has a chance to fail, but it more easier to succeed than without setting the test file and device.
    https://github.com/AgoraIO-Extensions/iris_method_channel_flutter/actions/runs/6329732359/job/17203218825

  17. kjxbyz commented on Oct 19, 2023

    @kjxbyz

    same issue

    ying@Kimmys-Mac-mini frontend-expert-app % make test_e2e
    echo "╠ Running E2E Testing..."
    ╠ Running E2E Testing...
    flutter test integration_test/demo_test.dart --flavor googleDev -d "emulator-5554"
    00:00 +0: loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart                                                                                                   R00:24 +0: loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart                                                                                              23.6s
    ✓  Built build/app/outputs/flutter-apk/app-googledev-debug.apk.
    00:25 +0: loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart                                                                                                   I00:27 +0: loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart                                                                                            1,526ms
    00:33 +0 -1: loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart [E]                                                                                            
      Failed to load "/Users/ying/work/frontend-expert-app/integration_test/demo_test.dart": Connecting to the VM Service timed out.
      package:flutter_tools/src/test/integration_test_device.dart 82:24  IntegrationTestTestDevice.start.<fn>
      dart:async/zone.dart 1391:47                                       _rootRun
      dart:async/zone.dart 1301:19                                       _CustomZone.run
      dart:async/future_impl.dart 938:34                                 Future.timeout.<fn>
      dart:async/zone.dart 1391:47                                       _rootRun
      dart:async/zone.dart 1301:19                                       _CustomZone.run
      dart:async/zone.dart 1209:7                                        _CustomZone.runGuarded
      dart:async/zone.dart 1249:23                                       _CustomZone.bindCallbackGuarded.<fn>
      dart:async/zone.dart 1399:13                                       _rootRun
      dart:async/zone.dart 1301:19                                       _CustomZone.run
      dart:async/zone.dart 1233:23                                       _CustomZone.bindCallback.<fn>
      dart:async-patch/timer_patch.dart 18:15                            Timer._createTimer.<fn>
      dart:isolate-patch/timer_impl.dart 398:19                          _Timer._runTimers
      dart:isolate-patch/timer_impl.dart 429:5                           _Timer._handleMessage
      dart:isolate-patch/isolate_patch.dart 189:12                       _RawReceivePort._handleMessage
      
    
    To run this test again: /Users/ying/flutter/bin/cache/dart-sdk/bin/dart test /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart -p vm --plain-name 'loading /Users/ying/work/frontend-expert-app/integration_test/demo_test.dart'
    00:34 +0 -1: Some tests failed.                                                                                                                                                          
    make: *** [test_e2e] Error 1
    
    [✓] Flutter (Channel stable, 3.13.8, on macOS 14.0 23A344 darwin-x64, locale zh-Hans-CN)
        • Flutter version 3.13.8 on channel stable at /Users/ying/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 6c4930c4ac (14 小时前), 2023-10-18 10:57:55 -0500
        • Engine revision 767d8c75e8
        • Dart version 3.1.4
        • DevTools version 2.25.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
        • Android SDK at /Users/ying/Android/sdk
        • Platform android-33, build-tools 33.0.2
        • ANDROID_HOME = /Users/ying/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.13.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • 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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.3)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 75.1.4
        • Dart plugin version 232.10072.19
    
    [!] Proxy Configuration
        • HTTP_PROXY is set
        ! NO_PROXY is not set
    
    [✓] Connected device (3 available)
        • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
        • macOS (desktop)              • macos         • darwin-x64     • macOS 14.0 23A344 darwin-x64
        • Chrome (web)                 • chrome        • web-javascript • Google Chrome 118.0.5993.88
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    
  18. matanlurey commented on May 23, 2025

    @matanlurey
    Contributor

    Could someone try this again with the latest stable version(s) of Flutter and let us know if this still is a problem?

  19. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 23, 2025
  20. top-master commented on May 30, 2025

    @top-master

    Root-cause of the issue

    Basically, most times the battery optimization kills the integration-test's APK.

    My company is 100% sure, since unless we enable "unrestricted" in battery settings, the tests fail 100% of the times we tried.

    Now once the tests pass the APK gets auto-uninstalled, and the settings restore to default. Hence see "Fix" section.

    Fix

    We fixed with following workaround:

    • You need to enable "stay awake" mode in Android-device's settings.

    • Then, each time before launching the tests, turn-on your Android-device's display.

    Note that said "stay awake" is too hard, also does not work in some devices, hence I use an App with the sole purpose of keeping screen on.

    Extra Note: There were many such Apps, and I tested many, however, only few keep the screen on.

  21. top-master commented on May 30, 2025

    @top-master

    @matanlurey Basically, this is a common Android issue as mentioned.

    Hence, I wonder how can a new Flutter version make any difference.

    We may need a "new Android version" and/or a "new adb version".

  22. github-actions commented on Jun 13, 2025

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  23. github-actions commented on Jun 27, 2025

    @github-actions

    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 flutter doctor -v and a minimal reproduction of the issue.

  24. locked as resolved and limited conversation to collaborators on Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.t: flutter driver"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions