mirror of
https://github.com/flutter/flutter
synced 2024-10-12 19:23:02 +00:00
[flutter_tools] remove timeout from iOS device startup (#81229)
This commit is contained in:
parent
ace61f01ef
commit
001323a275
|
@ -312,6 +312,7 @@ class IOSDevice extends Device {
|
|||
bool prebuiltApplication = false,
|
||||
bool ipv6 = false,
|
||||
String userIdentifier,
|
||||
@visibleForTesting Duration discoveryTimeout,
|
||||
}) async {
|
||||
String packageId;
|
||||
|
||||
|
@ -426,13 +427,12 @@ class IOSDevice extends Device {
|
|||
return LaunchResult.succeeded();
|
||||
}
|
||||
|
||||
_logger.printTrace('Application launched on the device. Waiting for observatory port.');
|
||||
Uri localUri;
|
||||
try {
|
||||
localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 30));
|
||||
} on TimeoutException {
|
||||
await observatoryDiscovery.cancel();
|
||||
}
|
||||
_logger.printTrace('Application launched on the device. Waiting for observatory url.');
|
||||
final Timer timer = Timer(discoveryTimeout ?? const Duration(seconds: 30), () {
|
||||
_logger.printError('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...');
|
||||
});
|
||||
final Uri localUri = await observatoryDiscovery.uri;
|
||||
timer.cancel();
|
||||
if (localUri == null) {
|
||||
iosDeployDebugger?.detach();
|
||||
return LaunchResult.failed();
|
||||
|
|
|
@ -178,6 +178,47 @@ void main() {
|
|||
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 {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
|
|
Loading…
Reference in a new issue