Skip to content

flutter_tester hangs on linux workstation #19273

Description

@gspencergoog

On my Linux workstation, running flutter tester just hangs and doesn't find a flutter view to run on.

Repro:

  1. flutter create mytest
  2. cd mytest
  3. flutter run -d flutter-tester --verbose
  4. fails with a stack trace and Error connecting to the service protocol: Exception: No Flutter view is available

The same thing works fine on my mac, and flutter tester tests seem to run fine on the bots.

I have tried:

  1. killing all flutter_tester processes (there were 10 running! I think it's not dying properly either).
  2. rebooting my machine
  3. nuking my cache directory and git pulling from master again.
  4. running flutter_tester manually directly. It runs and just sits there not reporting any errors.

I'm using master branch HEAD at 36e16e7.

Here's the entire output:

(home/gspencer:master) -- test_reload > flutter run -d flutter-tester --verbose
[  +42 ms] [/usr/local/google/home/gspencer/code/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +40 ms] Exit code 128 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] fatal: no upstream configured for branch 'master'
[        ] [/usr/local/google/home/gspencer/code/flutter/] git rev-parse --abbrev-ref HEAD
[   +6 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] master
[        ] [/usr/local/google/home/gspencer/code/flutter/] git log -n 1 --pretty=format:%H
[   +7 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 36e16e754433a1357e7f49af8c1221d70b67bc79
[        ] [/usr/local/google/home/gspencer/code/flutter/] git log -n 1 --pretty=format:%ar
[   +6 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 68 minutes ago
[   +1 ms] [/usr/local/google/home/gspencer/code/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +25 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v0.5.6-97-g36e16e754
[ +102 ms] /usr/local/google/home/gspencer/Android/Sdk/platform-tools/adb devices -l
[  +11 ms] Exit code 0 from: /usr/local/google/home/gspencer/Android/Sdk/platform-tools/adb devices -l
[        ] List of devices attached
           84B7N15A07007628       device usb:2-2.3 product:angler model:Nexus_6P device:angler transport_id:1
[ +210 ms] Found plugin shared_preferences at /usr/local/google/home/gspencer/code/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.2/
[ +792 ms] Launching lib/main.dart on Flutter test device in debug mode...
[ +389 ms] DependencyChecker: nothing is modified after 2018-07-11 10:44:23.408.
[ +208 ms] Skipping kernel compilation. Fingerprint match.
[ +285 ms] Building bundle
[        ] Writing asset files to build/flutter_assets
[  +66 ms] Wrote build/flutter_assets
[        ] /usr/local/google/home/gspencer/code/flutter/bin/cache/artifacts/engine/linux-x64/flutter_tester --run-forever --non-interactive --enable-dart-profiling --packages=.packages --flutter-assets-dir=build/flutter_assets build/app.dill
[ +243 ms] Observatory URL on device: http://127.0.0.1:34079/
[   +6 ms] Connecting to service protocol: http://127.0.0.1:34079/
[ +195 ms] Successfully connected to service protocol: http://127.0.0.1:34079/
[   +3 ms] getVM: {}
[  +11 ms] Waiting for Flutter view
[ +187 ms] Do not know weight for: TeXGyreSchola (BoldItalic) 
[ +813 ms] Waiting for Flutter view
[+1004 ms] Waiting for Flutter view
[+1000 ms] Waiting for Flutter view
[+1000 ms] Waiting for Flutter view
[+1002 ms] No Flutter views available on Flutter test device
[   +6 ms] Error connecting to the service protocol: Exception: No Flutter view is available
[  +21 ms] "flutter run" took 7,512ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:26)
#1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:406)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:347)
#3      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/dart:async/async_patch.dart:77)
#4      _rootRunUnary (dart:async/zone.dart:1134)
#5      _CustomZone.runUnary (dart:async/zone.dart:1031)
#6      _FutureListener.handleValue (dart:async/future_impl.dart:129)
#7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638)
#8      Future._propagateToListeners (dart:async/future_impl.dart:667)
#9      Future._complete (dart:async/future_impl.dart:472)
#10     _SyncCompleter.complete (dart:async/future_impl.dart:51)
#11     _AsyncAwaitCompleter.complete (dart:async-patch/dart:async/async_patch.dart:28)
#12     _completeOnAsyncReturn (dart:async-patch/dart:async/async_patch.dart:292)
#13     RunCommand.usageValues (package:flutter_tools/src/commands/run.dart:211)
#14     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/dart:async/async_patch.dart:77)
#15     _rootRunUnary (dart:async/zone.dart:1134)
#16     _CustomZone.runUnary (dart:async/zone.dart:1031)
#17     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#18     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638)
#19     Future._propagateToListeners (dart:async/future_impl.dart:667)
#20     Future._complete (dart:async/future_impl.dart:472)
#21     _SyncCompleter.complete (dart:async/future_impl.dart:51)
#22     _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async-patch/dart:async/async_patch.dart:33)
#23     _rootRun (dart:async/zone.dart:1126)
#24     _CustomZone.run (dart:async/zone.dart:1023)
#25     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#28     _runPendingImmediateCallback (dart:isolate-patch/dart:isolate/isolate_patch.dart:113)
#29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:166)

Activity

  1. added
    a: tests"flutter test", flutter_test, or one of our tests
    on Jul 11, 2018
  2. devoncarew commented on Jul 11, 2018

    @devoncarew
    Contributor
  3. DanTup commented on Jul 12, 2018

    @DanTup
    Contributor

    I think there are some flutter_tester tests in flutter_tools that just run non-Flutter Dart scripts - if you run it manually like that (which is just running the binary and giving it any old Dart file) does it work as expected (I think it should run the Dart script and then terminate at the end)?

  4. jason-simmons commented on Jul 13, 2018

    @jason-simmons
    Member

    In this scenario, the app is throwing an exception when run from flutter_tester on a Linux platform:

    This started with b3a6eda

    @Hixie

    The following assertion was thrown building MyApp(dirty):
    Unknown platform.
    linux was not recognized as a target platform. Consider updating the list of TargetPlatforms to
    include this platform.
    
    When the exception was thrown, this was the stack:
    #0      defaultTargetPlatform (package:flutter/src/foundation/platform.dart:67:5)
    #1      new ThemeData (package:flutter/src/material/theme_data.dart:185:18)
    #2      MyApp.build (file:///ssd2/test_examples/junk_createapp/lib/main.dart:11:18)
    #3      StatelessElement.build (package:flutter/src/widgets/framework.dart:3708:28)
    #4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3655:15)
    #5      Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
    #6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3635:5)
    #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3630:5)
    #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
    #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
    #10     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:857:16)
    #11     RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:828:5)
    #12     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:774:17)
    #13     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2235:19)
    #14     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:773:13)
    #15     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:662:7)
    #16     runApp (package:flutter/src/widgets/binding.dart:704:7)
    #17     main (file:///ssd2/test_examples/junk_createapp/lib/main.dart:3:16)
    #18     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
    #19     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
    
  5. DanTup commented on Jul 13, 2018

    @DanTup
    Contributor

    Ah yes :(

    Although, I don't think this is the real issue @gspencergoog was hitting when running the tests (which is why he was trying to use flutter-tester directly with flutter run) as when running the tests we set the FLUTTER_TEST env variable:

    return _processManager.start(
    command,
    workingDirectory: projectDir.path,
    environment: <String, String>{'FLUTTER_TEST': 'true'}

    Which forces Android:

    if (Platform.environment.containsKey('FLUTTER_TEST'))
    result = TargetPlatform.android;

  6. DanTup commented on Jul 13, 2018

    @DanTup
    Contributor

    Actually, we set this variable also when spawning flutter_tester from inside the tools:

    _process = await processManager.start(command,
    environment: <String, String>{
    'FLUTTER_TEST': 'true',
    },

    So it shouldn't be affecting flutter run -d flutter-tester either?

  7. jason-simmons commented on Jul 13, 2018

    @jason-simmons
    Member

    acf3f3d is causing flutter_tools to exit when used with -d flutter-tester.

    Prior to this change, flutter_tools would build and run the app code under flutter_tester and then query the service protocol for the list of Flutter views. The service protocol would return an empty list, and connectToServiceProtocol() would consider that acceptable. (Other service protocol operations like hot reload would not work though).

    WIth acf3f3d, flutter_tools will exit if the view list is empty.

  8. DanTup commented on Jul 16, 2018

    @DanTup
    Contributor

    I'm not sure what the expected behaviour - is it right that there are no views for a sample app created with flutter create? If not, is the change bad?

    (Also, why aren't any builds broken?)

  9. DanTup commented on Oct 8, 2018

    @DanTup
    Contributor

    Dart Code's integration tests are intermittently failing on Linux with this issue too:

    [11:51:32 GMT+0000 (UTC)] [CI] [Info] SPROC: Launching lib/main.dart on Flutter test device in debug mode...
    [11:51:45 GMT+0000 (UTC)] [CI] [Info] SPROC: No Flutter views available on Flutter test device
    [11:51:45 GMT+0000 (UTC)] [CI] [Info] SPROC: Error connecting to the service protocol: Exception: No Flutter view is available
    [11:51:45 GMT+0000 (UTC)] [CI] [Info] SPROC:
    [11:51:45 GMT+0000 (UTC)] [CI] [Info] SPROC: Exited (2)
    

    I don't know if it's gotten worse but I do seem to have a lot of failures on Linux lately (these aren't all the issue described here, but all the failures are on Linux - orange is skipped, not flaky!).

    screen shot 2018-10-08 at 8 05 31 am

  10. DanTup commented on Oct 8, 2018

    @DanTup
    Contributor

    Actually, looking at a few results, it seems like this might have regressed. The flutter attach tests are failing with this on master (2nd + 4th cols) but passing on beta (1st + 3rd cols). Appears consistent across the last few test runs I've looked at.

    Edit: There are other tests failing for the same reason on beta too, so it seems this issue isn't exclude to master (though it does seem consistent on the attach test - could be complete coincidence).

  11. Hixie commented on Oct 18, 2018

    @Hixie
    Contributor

    I see this on master now:

    $ cd ~/dev/flutter/packages/flutter_tools
    $ ../../bin/cache/dart-sdk/bin/pub run test -j 1 --reporter expanded test/integration/hot_reload_test.dart
    00:00 +0: hot reload works without error
    00:07 +0 -1: hot reload works without error [E]
      Received app.stop event while waiting for app.started event.
    
    
      dart:async                                _Completer.completeError
      test/integration/test_driver.dart 333:18  FlutterTestDriver._waitFor.<fn>
      ===== asynchronous gap ===========================
      dart:async                                _asyncThenWrapperHelper
      test/integration/test_driver.dart         FlutterTestDriver._waitFor.<fn>
      ===== asynchronous gap ===========================
      dart:async                                _StreamImpl.listen
      test/integration/test_driver.dart 313:26  FlutterTestDriver._waitFor
      ===== asynchronous gap ===========================
      dart:async                                _asyncThenWrapperHelper
      test/integration/test_driver.dart         FlutterTestDriver._setupProcess
      test/integration/test_driver.dart 60:11   FlutterTestDriver.run
    
  12. jason-simmons commented on Oct 18, 2018

    @jason-simmons
    Member

    test/integration/hot_reload_test regressed in fd8a960

  13. DanTup commented on Oct 19, 2018

    @DanTup
    Contributor

    @Hixie @jason-simmons Can either of you reproduce it with the debug printing turned on (_printJsonAndStderr in test_driver.dart)? I can't repro locally (though I do see #23285).

    I'll see if I can improve this error too; it should probably include the last few events it received in the message.

  14. DanTup commented on Oct 19, 2018

    @DanTup
    Contributor

    (I just realised the title here mentions Linux - is that where you're seeing this? I've been testing on macOS)

  15. DanTup commented on Oct 19, 2018

    @DanTup
    Contributor

    With the change in #23287 the error above should include the recent messages received from the flutter run process. This should make it easier to understand the failure without having to enable verbose/debug logging (which is trickier for CIs).

    @Hixie If you patch that change in and repro the issue does it give a better indication of what failed?

    Example output:

    00:19 +0 -1: hot reload works without error [E]                                                                                                                
      Received app.stop event while waiting for app.started event.
      
      
      Received:
      [+   195] [{"event":"app.start","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab","deviceId":"flutter-tester","directory":"/private/var/folders/8r/5r4vmgn94h9fy343vxdvr4_r00hbgw/T/flutter_hot_reload_test_app.ZvM5t6","supportsRestart":true}}]
      [+   793] Launching lib/main.dart on Flutter test device in debug mode...
      [+  5152] topLevelFunction
      [+  5244] [{"event":"app.debugPort","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab","port":50874,"wsUri":"ws://127.0.0.1:50874/ws","baseUri":"file:///var/folders/8r/5r4vmgn94h9fy343vxdvr4_r00hbgw/T/flutter_hot_reload_test_app.ZvM5t6uKdtGb/flutter_hot_reload_test_app.ZvM5t6/"}}]
      [+  5289] [{"event":"app.progress","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab","id":"0","progressId":null,"message":"Syncing files to device Flutter test device..."}}]
      [+  8861] [{"event":"app.progress","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab","id":"0","progressId":null,"finished":true}}]
      [+  8870] [{"event":"app.started","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab"}}]
      [+ 10445] Lost connection to device.
      [+ 10709] [{"event":"app.stop","params":{"appId":"81a63a61-3820-4cf1-b7ad-7df5fe0f74ab"}}]
      
      test/integration/test_driver.dart 362:7   FlutterTestDriver._timeoutWithMessages.<fn>
      ===== asynchronous gap ===========================
      dart:async                                Future.catchError
      test/integration/test_driver.dart 361:8   FlutterTestDriver._timeoutWithMessages
      test/integration/test_driver.dart 339:12  FlutterTestDriver._waitFor
      ===== asynchronous gap ===========================
      dart:async                                _asyncThenWrapperHelper
      test/integration/test_driver.dart         FlutterTestDriver._setupProcess
      test/integration/test_driver.dart 60:11   FlutterTestDriver.run
    
  16. 18 remaining items

  17. vineetkala11 commented on Nov 9, 2018

    @vineetkala11

    I am facing same issue with window -

    Launching lib\main.dart on Android SDK built for x86 in debug mode...
    Initializing gradle...
    Resolving dependencies...
    Gradle task 'assembleDebug'...
    Built build\app\outputs\apk\debug\app-debug.apk.
    No Flutter views available on Android SDK built for x86
    Error connecting to the service protocol: Exception: No Flutter view is available

  18. dnfield commented on Nov 9, 2018

    @dnfield
    Contributor

    @vineetkala11 can you try latest on master and see if it still reproduces? The patch for this just landed an about an hour ago.

  19. vineetkala11 commented on Nov 9, 2018

    @vineetkala11

    Using Command as Administrator solves my problem.

  20. bormisov1 commented on Nov 12, 2018

    @bormisov1

    @dnfield
    I'm having the same Error connecting to the service protocol: Exception: No Flutter view is available when I run my project in VS Code

    vlad@Xiaomi:~/Work/flutter_token_way$ flutter doctor -v
    [✓] Flutter (Channel beta, v0.10.2, on Linux, locale en_US.UTF-8)
        • Flutter version 0.10.2 at /home/vlad/Work/flutter
        • Framework revision d8cbb80206 (2 недели назад), 2018-10-26 01:30:21 -0400
        • Engine revision 6c2ade9fa2
        • Dart version 2.1.0-dev.8.0.flutter-bf26f760b1
    
    [✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
        • Android SDK at /home/vlad/Android/Sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.3
        • Java binary at: /usr/local/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
        • All Android licenses accepted.
    
    [✓] Android Studio (version 3.2)
        • Android Studio at /usr/local/android-studio
        • Flutter plugin version 29.1.1
        • Dart plugin version 181.5656
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    
    [!] VS Code (version 1.28.2)
        • VS Code at /usr/share/code
        • Flutter extension not installed; install from
          https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (1 available)
        • Redmi 4X • 7d4983c7d740 • android-arm64 • Android 7.1.2 (API 25)
    
    ! Doctor found issues in 1 category.
    

    At first I thought that maybe it didn't update properly and ran commands below in flutter directory, but the error still appears when I run the app for the first time after some pause (second and third launches in a row are ok)

    git clean -xfd
    git pull
    flutter doctor
    
  21. tvolkert commented on Nov 13, 2018

    @tvolkert
    Contributor

    @bormisov1 #23835 hasn't made it to the beta channel yet. You can try on the master channel to test it with the fix.

  22. github-actions commented on Sep 1, 2021

    @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.

  23. locked as resolved and limited conversation to collaborators on Sep 1, 2021
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

    a: tests"flutter test", flutter_test, or one of our tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions