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 {
final VMServiceClientConnection connection =
await vmServiceConnectFunction(dartVmServiceUrl, headers: headers);
final VMServiceClient client = connection.client;
final VM vm = await client.getVM();
final VMIsolateRef isolateRef = isolateNumber ==
null ? vm.isolates.first :
vm.isolates.firstWhere(
(VMIsolateRef isolate) => isolate.number == isolateNumber);
Future<VMIsolateRef> _waitForRootIsolate() async {
bool _checkIsolate(VMIsolateRef ref) => ref.number == isolateNumber;
while (true) {
final VM vm = await client.getVM();
if (vm.isolates.isEmpty || (isolateNumber != null && !vm.isolates.any(_checkIsolate))) {
await Future<void>.delayed(_kPauseBetweenReconnectAttempts);
continue;
}
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}');
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