Repository navigation
Connect to VM timeout when doing integration tests #50898
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.t: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
Description
Steps to Reproduce
- Run
flutter drive --target=test_driver/app.dart. - 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
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 listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.t: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
Activity
jagsme commentedon Feb 17, 2020
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
TahaTesser commentedon Feb 17, 2020
Could be related #34196
jagsme commentedon Feb 17, 2020
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
jagsme commentedon Feb 18, 2020
@TahaTesser
the issue is fixed when we upgrade flutter version to Flutter 1.12.13+hotfix.8.
tianhaoz95 commentedon Feb 18, 2020
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.
tianhaoz95 commentedon Feb 21, 2020
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.
HerrNiklasRaab commentedon Feb 25, 2020
@tianhaoz95
Upgrading to 1.12.13+hotfix.8 fixed it for me
tianhaoz95 commentedon Feb 25, 2020
@HerrNiklasRaab can you add the channel you were on? I tried stable. Maybe dev should be better?
HerrNiklasRaab commentedon Feb 25, 2020
I was on stable to:
20 remaining items
Kiruel commentedon Nov 23, 2022
Got the same problem on flutter 3.3.8 on emulator iPhone 14 pro max.
praxder commentedon Dec 1, 2022
Same issue here. Keeping us from being able to use integration tests since they can't be run consistently in CI/CD.
bartekpacia commentedon Dec 1, 2022
This was mostly fixed in #113969 by the awesome @jakubfijalkowski. Should be available in the next stable Flutter release.
littleGnAl commentedon Sep 28, 2023
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" --verboseit 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
kjxbyz commentedon Oct 19, 2023
same issue
matanlurey commentedon May 23, 2025
Could someone try this again with the latest stable version(s) of Flutter and let us know if this still is a problem?
top-master commentedon May 30, 2025
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.
top-master commentedon May 30, 2025
@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".
github-actions commentedon Jun 13, 2025
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.
github-actions commentedon Jun 27, 2025
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 -vand a minimal reproduction of the issue.