Unverified Commit 9951638f authored by Dan Field's avatar Dan Field Committed by GitHub

retry getting the main isolate (#68894)

parent ec0a7574
...@@ -96,11 +96,28 @@ class VMServiceFlutterDriver extends FlutterDriver { ...@@ -96,11 +96,28 @@ class VMServiceFlutterDriver extends FlutterDriver {
final VMServiceClientConnection connection = final VMServiceClientConnection connection =
await vmServiceConnectFunction(dartVmServiceUrl, headers: headers); await vmServiceConnectFunction(dartVmServiceUrl, headers: headers);
final VMServiceClient client = connection.client; final VMServiceClient client = connection.client;
Future<VMIsolateRef> _waitForRootIsolate() async {
bool _checkIsolate(VMIsolateRef ref) => ref.number == isolateNumber;
while (true) {
final VM vm = await client.getVM(); final VM vm = await client.getVM();
final VMIsolateRef isolateRef = isolateNumber == if (vm.isolates.isEmpty || (isolateNumber != null && !vm.isolates.any(_checkIsolate))) {
null ? vm.isolates.first : await Future<void>.delayed(_kPauseBetweenReconnectAttempts);
vm.isolates.firstWhere( continue;
(VMIsolateRef isolate) => isolate.number == isolateNumber); }
return isolateNumber == null
? vm.isolates.first
: vm.isolates.firstWhere(_checkIsolate);
}
}
final VMIsolateRef isolateRef = await _warnIfSlow<VMIsolateRef>(
future: _waitForRootIsolate(),
timeout: kUnusuallyLongTimeout,
message: isolateNumber == null
? 'The root isolate is taking an unuusally long time to start.'
: 'Isolate $isolateNumber is taking an unusually long time to start.',
);
_log('Isolate found with number: ${isolateRef.number}'); _log('Isolate found with number: ${isolateRef.number}');
VMIsolate isolate = await isolateRef.loadRunnable(); VMIsolate isolate = await isolateRef.loadRunnable();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment