If one method of finding Dart VM fails for CoreDevice, wait for the other method (#139754)

For CoreDevices we use a combination of mDNS and device logs to find the Dart VM url. If mDNS fails first, it will cause the launch to fail even though the device logs may be able to find the url. So if one of the methods fails, wait for the other method before failing the launch.

Fixes https://github.com/flutter/flutter/issues/139685.
This commit is contained in:
Victoria Ashworth
2023-12-08 10:39:08 -06:00
committed by GitHub
parent 0c0b77f342
commit 82bc9ca327
2 changed files with 79 additions and 0 deletions

View File

@@ -680,6 +680,14 @@ class IOSDevice extends Device {
localUri = await Future.any(
<Future<Uri?>>[vmUrlFromMDns, vmUrlFromLogs]
);
// If the first future to return is null, wait for the other to complete.
if (localUri == null) {
final List<Uri?> vmUrls = await Future.wait(
<Future<Uri?>>[vmUrlFromMDns, vmUrlFromLogs]
);
localUri = vmUrls.where((Uri? vmUrl) => vmUrl != null).firstOrNull;
}
} else {
localUri = await vmServiceDiscovery?.uri;
// If the `ios-deploy` debugger loses connection before it finds the