Repository: flutter
Issue: Flutter driver timeout cause test to fail
Labels: framework,t: flutter driver,P2,team-framework,triaged-framework

Flutter driver timeout cause test to fail on linux emulator, docker android emulator and macos mojave android emulator and real android device

## Steps to Reproduce
Follow the steps on https://flutter.dev/docs/cookbook/testing/integration/introduction

**Target Platform: Android **
**Target OS version/browser: 25++**
**Devices: Emulator**


## Logs

flutter drive --debug --target=test_driver/app.dart
```
Using device Android SDK built for x86 64.
Starting application: test_driver/app.dart
Initializing gradle...                                             10.7s
Resolving dependencies...                                          59.7s
"build/app/outputs/apk/app.apk" does not exist.
Running Gradle task 'assembleDebug'...                             47.1s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...                       408.9s (!)
I/flutter ( 5096): Observatory listening on http://127.0.0.1:42379/LdGM3IHbn2o=/
00:00 [32m+0[0m: Counter App (setUpAll)[0m
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:33749/LdGM3IHbn2o=/
[trace] FlutterDriver: Isolate found with number: 2862227988220383
[warning] FlutterDriver: Unknown pause event type VMNoneEvent. Assuming application is ready.
00:15 [32m+0[0m[31m -1[0m: Counter App (setUpAll) [1m[31m[E][0m[0m
  JSON-RPC error -32601 (method not found): Method not found
  package:json_rpc_2/src/client.dart 110:64          Client.sendRequest
  package:json_rpc_2/src/peer.dart 79:15             Peer.sendRequest
  package:vm_service_client/src/scope.dart 64:23     Scope.sendRequestRaw
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053:19                       _CustomZone.registerUnaryCallback
  dart:async-patch/async_patch.dart 71:23            _asyncThenWrapperHelper
  package:flutter_driver/src/driver/driver.dart      FlutterDriver.connect
  test_driver/app_test.dart 18:36                    main.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053:19                       _CustomZone.registerUnaryCallback
  dart:async/zone.dart 967:22                        _CustomZone.bindUnaryCallbackGuarded
  dart:async/future.dart 530:34                      Future.doWhile
  dart:async/future.dart 490:12                      Future.forEach
  package:test_api/src/backend/declarer.dart 291:36  Declarer._setUpAll.<fn>.<fn>
  dart:async/zone.dart 1124:13                       _rootRun
  dart:async/zone.dart 1021:19                       _CustomZone.run
  dart:async/zone.dart 1516:10                       _runZoned
  dart:async/zone.dart 1463:12                       runZoned
  package:test_api/src/backend/declarer.dart 291:14  Declarer._setUpAll.<fn>
  package:test_api/src/backend/invoker.dart 400:25   Invoker._onRun.<fn>.<fn>.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                       _CustomZone.registerCallback
  dart:async/zone.dart 962:22                        _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52:45                        new Timer
  dart:async/timer.dart 87:9                         Timer.run
  dart:async/future.dart 174:11                      new Future
  package:test_api/src/backend/invoker.dart 399:21   Invoker._onRun.<fn>.<fn>.<fn>

  DriverError: Failed to fulfill GetHealth due to remote error
  Original error: JSON-RPC error -32601 (method not found): Method not found
  Original stack trace:
  package:json_rpc_2/src/client.dart 110:64          Client.sendRequest
  package:json_rpc_2/src/peer.dart 79:15             Peer.sendRequest
  package:vm_service_client/src/scope.dart 64:23     Scope.sendRequestRaw
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053:19                       _CustomZone.registerUnaryCallback
  dart:async-patch/async_patch.dart 71:23            _asyncThenWrapperHelper
  package:flutter_driver/src/driver/driver.dart      FlutterDriver.connect
  test_driver/app_test.dart 18:36                    main.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053:19                       _CustomZone.registerUnaryCallback
  dart:async/zone.dart 967:22                        _CustomZone.bindUnaryCallbackGuarded
  dart:async/future.dart 530:34                      Future.doWhile
  dart:async/future.dart 490:12                      Future.forEach
  package:test_api/src/backend/declarer.dart 291:36  Declarer._setUpAll.<fn>.<fn>
  dart:async/zone.dart 1124:13                       _rootRun
  dart:async/zone.dart 1021:19                       _CustomZone.run
  dart:async/zone.dart 1516:10                       _runZoned
  dart:async/zone.dart 1463:12                       runZoned
  package:test_api/src/backend/declarer.dart 291:14  Declarer._setUpAll.<fn>
  package:test_api/src/backend/invoker.dart 400:25   Invoker._onRun.<fn>.<fn>.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                       _CustomZone.registerCallback
  dart:async/zone.dart 962:22                        _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52:45                        new Timer
  dart:async/timer.dart 87:9                         Timer.run
  dart:async/future.dart 174:11                      new Future
  package:test_api/src/backend/invoker.dart 399:21   Invoker._onRun.<fn>.<fn>.<fn>


  package:flutter_driver/src/driver/driver.dart 448:7           FlutterDriver._sendCommand
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1062:19                                  _CustomZone.registerBinaryCallback
  dart:async-patch/async_patch.dart 80:23                       _asyncErrorWrapperHelper
  package:test_api/src/backend/invoker.dart                     Invoker._onRun.<fn>.<fn>.<fn>.<fn>
  dart:async/future.dart 176:37                                 new Future.<fn>
  package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 119:48  StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1120:38                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  dart:async/zone.dart 923:7                                    _CustomZone.runGuarded
  dart:async/zone.dart 963:23                                   _CustomZone.bindCallbackGuarded.<fn>
  package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 119:48  StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1124:13                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  dart:async/zone.dart 947:23                                   _CustomZone.bindCallback.<fn>
  dart:async-patch/timer_patch.dart 21:15                       Timer._createTimer.<fn>
  dart:isolate-patch/timer_impl.dart 382:19                     _Timer._runTimers
  dart:isolate-patch/timer_impl.dart 416:5                      _Timer._handleMessage
  dart:isolate-patch/isolate_patch.dart 172:12                  _RawReceivePortImpl._handleMessage
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                                  _CustomZone.registerCallback
  dart:async/zone.dart 962:22                                   _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52:45                                   new Timer
  dart:async/timer.dart 87:9                                    Timer.run
  dart:async/future.dart 174:11                                 new Future
  package:test_api/src/backend/invoker.dart 399:21              Invoker._onRun.<fn>.<fn>.<fn>

00:15 [32m+0[0m[31m -1[0m: Counter App (tearDownAll)[0m
00:15 [32m+0[0m[31m -1[0m: [31mSome tests failed.[0m

Unhandled exception:
Dummy exception to set exit code.
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
#4      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
Stopping application instance.
Driver tests failed: 255
```