Workaround for Dart VM timeout (#127875)
Workaround solution for: https://github.com/flutter/flutter/issues/121231
See https://github.com/flutter/flutter/issues/120808#issuecomment-1551826299 Error Case 2 for more information.
Sometimes the `ios-deploy` process does not return the logs from the application. We've been unable to figure out why. This is a solution to workaround that by using `idevicesyslog` alongside `ios-deploy` as a backup in getting the log for the Dart VM url. As explained in https://github.com/flutter/flutter/issues/120808#issuecomment-1551826299, when error case 2 happens, the `idevicesyslog` does successfully find the Dart VM.
Also, in the comments of the code it mentions `syslog` is not written on iOS 13+, this was added in response to this issue: https://github.com/flutter/flutter/issues/41133.
However, `idevicesyslog` does in fact work (at least for iOS 16), we use it to collect device logs for our CI tests already: 1dc26f80f0/dev/devicelab/lib/framework/devices.dart (L998-L1006)
This commit is contained in:
committed by
GitHub
parent
95cd3c0340
commit
cd18c8c02f
@@ -1381,6 +1381,7 @@ class FakeIOSDevice extends Fake implements IOSDevice {
|
||||
DeviceLogReader getLogReader({
|
||||
IOSApp? app,
|
||||
bool includePastLogs = false,
|
||||
bool usingCISystem = false,
|
||||
}) {
|
||||
if (onGetLogReader == null) {
|
||||
throw UnimplementedError(
|
||||
|
||||
@@ -425,6 +425,7 @@ void main() {
|
||||
'--enable-software-rendering',
|
||||
'--skia-deterministic-rendering',
|
||||
'--enable-embedder-api',
|
||||
'--ci',
|
||||
]), throwsToolExit());
|
||||
|
||||
final DebuggingOptions options = await command.createDebuggingOptions(false);
|
||||
@@ -440,6 +441,7 @@ void main() {
|
||||
expect(options.traceSystrace, true);
|
||||
expect(options.enableSoftwareRendering, true);
|
||||
expect(options.skiaDeterministicRendering, true);
|
||||
expect(options.usingCISystem, true);
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
|
||||
@@ -1096,6 +1096,7 @@ void main() {
|
||||
'--enable-software-rendering',
|
||||
'--skia-deterministic-rendering',
|
||||
'--enable-embedder-api',
|
||||
'--ci',
|
||||
]), throwsToolExit());
|
||||
|
||||
final DebuggingOptions options = await command.createDebuggingOptions(false);
|
||||
@@ -1114,6 +1115,7 @@ void main() {
|
||||
expect(options.impellerForceGL, true);
|
||||
expect(options.enableSoftwareRendering, true);
|
||||
expect(options.skiaDeterministicRendering, true);
|
||||
expect(options.usingCISystem, true);
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
|
||||
@@ -30,11 +30,53 @@ void main() {
|
||||
}
|
||||
}));
|
||||
|
||||
testUsingContext('Global arg results are available in FlutterCommands', () async {
|
||||
final DummyFlutterCommand command = DummyFlutterCommand(
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
|
||||
|
||||
runner.addCommand(command);
|
||||
await runner.run(<String>['dummy', '--${FlutterGlobalOptions.kContinuousIntegrationFlag}']);
|
||||
|
||||
expect(command.globalResults, isNotNull);
|
||||
expect(command.boolArg(FlutterGlobalOptions.kContinuousIntegrationFlag, global: true), true);
|
||||
});
|
||||
|
||||
testUsingContext('Global arg results are available in FlutterCommands sub commands', () async {
|
||||
final DummyFlutterCommand command = DummyFlutterCommand(
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
|
||||
final DummyFlutterCommand subcommand = DummyFlutterCommand(
|
||||
name: 'sub',
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
|
||||
command.addSubcommand(subcommand);
|
||||
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
|
||||
|
||||
runner.addCommand(command);
|
||||
runner.addCommand(subcommand);
|
||||
await runner.run(<String>['dummy', 'sub', '--${FlutterGlobalOptions.kContinuousIntegrationFlag}']);
|
||||
|
||||
expect(subcommand.globalResults, isNotNull);
|
||||
expect(subcommand.boolArg(FlutterGlobalOptions.kContinuousIntegrationFlag, global: true), true);
|
||||
});
|
||||
|
||||
testUsingContext('bool? safe argResults', () async {
|
||||
final DummyFlutterCommand command = DummyFlutterCommand(
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
}
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
|
||||
command.argParser.addFlag('key');
|
||||
@@ -58,9 +100,9 @@ void main() {
|
||||
|
||||
testUsingContext('String? safe argResults', () async {
|
||||
final DummyFlutterCommand command = DummyFlutterCommand(
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
}
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
|
||||
command.argParser.addOption('key');
|
||||
@@ -80,9 +122,9 @@ void main() {
|
||||
|
||||
testUsingContext('List<String> safe argResults', () async {
|
||||
final DummyFlutterCommand command = DummyFlutterCommand(
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
}
|
||||
commandFunction: () async {
|
||||
return const FlutterCommandResult(ExitStatus.success);
|
||||
},
|
||||
);
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: true);
|
||||
command.argParser.addMultiOption(
|
||||
|
||||
@@ -348,6 +348,165 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('both syslog and debugger stream', () {
|
||||
|
||||
testWithoutContext('useBothLogDeviceReaders is true when CI option is true and sdk is at least 16', () {
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
usingCISystem: true,
|
||||
majorSdkVersion: 16,
|
||||
);
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('useBothLogDeviceReaders is false when sdk is less than 16', () {
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
usingCISystem: true,
|
||||
majorSdkVersion: 15,
|
||||
);
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('useBothLogDeviceReaders is false when CI option is false', () {
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
majorSdkVersion: 16,
|
||||
);
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('syslog only sends flutter messages to stream when useBothLogDeviceReaders is true', () async {
|
||||
processManager.addCommand(
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
ideviceSyslogPath, '-u', '1234',
|
||||
],
|
||||
stdout: '''
|
||||
Runner(Flutter)[297] <Notice>: A is for ari
|
||||
Runner(Flutter)[297] <Notice>: I is for ichigo
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: This is a test
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
|
||||
'''
|
||||
),
|
||||
);
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
usingCISystem: true,
|
||||
majorSdkVersion: 16,
|
||||
);
|
||||
final List<String> lines = await logReader.logLines.toList();
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isTrue);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
expect(lines, <String>[
|
||||
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
|
||||
'flutter: This is a test'
|
||||
]);
|
||||
});
|
||||
|
||||
testWithoutContext('IOSDeviceLogReader uses both syslog and ios-deploy debugger', () async {
|
||||
processManager.addCommand(
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
ideviceSyslogPath, '-u', '1234',
|
||||
],
|
||||
stdout: '''
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: Check for duplicate
|
||||
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
|
||||
'''
|
||||
),
|
||||
);
|
||||
|
||||
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
|
||||
'2023-06-01 12:49:01.445093-0500 Runner[2225:533240] flutter: Check for duplicate',
|
||||
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
|
||||
]);
|
||||
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
usingCISystem: true,
|
||||
majorSdkVersion: 16,
|
||||
);
|
||||
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
|
||||
iosDeployDebugger.logLines = debuggingLogs;
|
||||
logReader.debuggerStream = iosDeployDebugger;
|
||||
final Future<List<String>> logLines = logReader.logLines.toList();
|
||||
final List<String> lines = await logLines;
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isTrue);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
expect(lines.length, 3);
|
||||
expect(lines, containsAll(<String>[
|
||||
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
|
||||
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
|
||||
'flutter: Check for duplicate',
|
||||
]));
|
||||
|
||||
});
|
||||
|
||||
testWithoutContext('IOSDeviceLogReader only uses ios-deploy debugger when useBothLogDeviceReaders is false', () async {
|
||||
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
|
||||
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
|
||||
'',
|
||||
]);
|
||||
|
||||
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
|
||||
iMobileDevice: IMobileDevice(
|
||||
artifacts: artifacts,
|
||||
processManager: processManager,
|
||||
cache: fakeCache,
|
||||
logger: logger,
|
||||
),
|
||||
majorSdkVersion: 16,
|
||||
);
|
||||
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
|
||||
iosDeployDebugger.logLines = debuggingLogs;
|
||||
logReader.debuggerStream = iosDeployDebugger;
|
||||
final Future<List<String>> logLines = logReader.logLines.toList();
|
||||
final List<String> lines = await logLines;
|
||||
|
||||
expect(logReader.useBothLogDeviceReaders, isFalse);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
expect(
|
||||
lines.contains(
|
||||
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class FakeIOSDeployDebugger extends Fake implements IOSDeployDebugger {
|
||||
|
||||
Reference in New Issue
Block a user