Unverified Commit 001323a2 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove timeout from iOS device startup (#81229)

parent ace61f01
...@@ -312,6 +312,7 @@ class IOSDevice extends Device { ...@@ -312,6 +312,7 @@ class IOSDevice extends Device {
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String userIdentifier,
@visibleForTesting Duration discoveryTimeout,
}) async { }) async {
String packageId; String packageId;
...@@ -426,13 +427,12 @@ class IOSDevice extends Device { ...@@ -426,13 +427,12 @@ class IOSDevice extends Device {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
_logger.printTrace('Application launched on the device. Waiting for observatory port.'); _logger.printTrace('Application launched on the device. Waiting for observatory url.');
Uri localUri; final Timer timer = Timer(discoveryTimeout ?? const Duration(seconds: 30), () {
try { _logger.printError('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...');
localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 30)); });
} on TimeoutException { final Uri localUri = await observatoryDiscovery.uri;
await observatoryDiscovery.cancel(); timer.cancel();
}
if (localUri == null) { if (localUri == null) {
iosDeployDebugger?.detach(); iosDeployDebugger?.detach();
return LaunchResult.failed(); return LaunchResult.failed();
......
...@@ -178,6 +178,47 @@ void main() { ...@@ -178,6 +178,47 @@ void main() {
expect(await device.stopApp(iosApp), false); expect(await device.stopApp(iosApp), false);
}); });
testWithoutContext('IOSDevice.startApp prints warning message if discovery takes longer than configured timeout', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
kAttachDebuggerCommand,
]);
final IOSDevice device = setUpIOSDevice(
processManager: processManager,
fileSystem: fileSystem,
logger: logger,
);
final IOSApp iosApp = PrebuiltIOSApp(
projectBundleId: 'app',
bundleName: 'Runner',
bundleDir: fileSystem.currentDirectory,
);
final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader();
device.portForwarder = const NoOpDevicePortForwarder();
device.setLogReader(iosApp, deviceLogReader);
// Start writing messages to the log reader.
Timer.run(() async {
await Future<void>.delayed(const Duration(milliseconds: 1));
deviceLogReader.addLine('Foo');
deviceLogReader.addLine('Observatory listening on http://127.0.0.1:456');
});
final LaunchResult launchResult = await device.startApp(iosApp,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
platformArgs: <String, dynamic>{},
discoveryTimeout: Duration.zero,
);
expect(launchResult.started, true);
expect(launchResult.hasObservatory, true);
expect(await device.stopApp(iosApp), false);
expect(logger.errorText, contains('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...'));
});
testWithoutContext('IOSDevice.startApp succeeds in release mode', () async { testWithoutContext('IOSDevice.startApp succeeds in release mode', () async {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
......
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