Add more supported simulator debugging options and improve tests (#114628)

* add debugging options to simulator, test more debugging flags, add tests for other launch arguements

* refactor iOS launch arguments to use one function for both simulator and physical devices

* treat dart flags differently between physical and simulator

* Simplify some flags between devices.

Change --disable-service-auth-codes to not always be included for physical devices, only if disableServiceAuthCodes is true.
Change --disable-observatory-publication to be used for simulator devices too.
Change --enable-checked-mode & --verify-entry-points to be used if debuggingEnabled is true regardless of device type.
Chnage --trace-startup to be used for simulator devices too.

* fix ios release mode with buildable app startApp test

* determine observatory-port from deviceVmServicePort and hostVmServicePort

* add comments and remove hasObservatoryPort
This commit is contained in:
Victoria Ashworth
2022-11-09 12:17:09 -06:00
committed by GitHub
parent d3dcd7d532
commit 3a656b16cb
8 changed files with 413 additions and 57 deletions

View File

@@ -913,7 +913,45 @@ class DebuggingOptions {
/// * https://github.com/dart-lang/sdk/blob/main/sdk/lib/html/doc/NATIVE_NULL_ASSERTIONS.md
final bool nativeNullAssertions;
bool get hasObservatoryPort => hostVmServicePort != null;
List<String> getIOSLaunchArguments(EnvironmentType environmentType, String? route, Map<String, Object?> platformArgs) {
final String dartVmFlags = computeDartVmFlags(this);
return <String>[
'--enable-dart-profiling',
if (disableServiceAuthCodes) '--disable-service-auth-codes',
if (disablePortPublication) '--disable-observatory-publication',
if (startPaused) '--start-paused',
// Wrap dart flags in quotes for physical devices
if (environmentType == EnvironmentType.physical && dartVmFlags.isNotEmpty)
'--dart-flags="$dartVmFlags"',
if (environmentType == EnvironmentType.simulator && dartVmFlags.isNotEmpty)
'--dart-flags=$dartVmFlags',
if (useTestFonts) '--use-test-fonts',
if (debuggingEnabled) ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
if (enableSoftwareRendering) '--enable-software-rendering',
if (traceSystrace) '--trace-systrace',
if (skiaDeterministicRendering) '--skia-deterministic-rendering',
if (traceSkia) '--trace-skia',
if (traceAllowlist != null) '--trace-allowlist="$traceAllowlist"',
if (traceSkiaAllowlist != null) '--trace-skia-allowlist="$traceSkiaAllowlist"',
if (endlessTraceBuffer) '--endless-trace-buffer',
if (dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation',
if (verboseSystemLogs) '--verbose-logging',
if (cacheSkSL) '--cache-sksl',
if (purgePersistentCache) '--purge-persistent-cache',
if (route != null) '--route=$route',
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
if (enableImpeller) '--enable-impeller',
if (environmentType == EnvironmentType.physical && deviceVmServicePort != null)
'--observatory-port=$deviceVmServicePort',
// The simulator "device" is actually on the host machine so no ports will be forwarded.
// Use the suggested host port.
if (environmentType == EnvironmentType.simulator && hostVmServicePort != null)
'--observatory-port=$hostVmServicePort',
];
}
Map<String, Object?> toJson() => <String, Object?>{
'debuggingEnabled': debuggingEnabled,

View File

@@ -348,34 +348,11 @@ class IOSDevice extends Device {
}
// Step 3: Attempt to install the application on the device.
final String dartVmFlags = computeDartVmFlags(debuggingOptions);
final List<String> launchArguments = <String>[
'--enable-dart-profiling',
'--disable-service-auth-codes',
if (debuggingOptions.disablePortPublication) '--disable-observatory-publication',
if (debuggingOptions.startPaused) '--start-paused',
if (dartVmFlags.isNotEmpty) '--dart-flags="$dartVmFlags"',
if (debuggingOptions.useTestFonts) '--use-test-fonts',
if (debuggingOptions.debuggingEnabled) ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',
if (debuggingOptions.traceSystrace) '--trace-systrace',
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
if (debuggingOptions.traceSkia) '--trace-skia',
if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"',
if (debuggingOptions.traceSkiaAllowlist != null) '--trace-skia-allowlist="${debuggingOptions.traceSkiaAllowlist}"',
if (debuggingOptions.endlessTraceBuffer) '--endless-trace-buffer',
if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation',
if (debuggingOptions.verboseSystemLogs) '--verbose-logging',
if (debuggingOptions.cacheSkSL) '--cache-sksl',
if (debuggingOptions.purgePersistentCache) '--purge-persistent-cache',
if (route != null) '--route=$route',
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
if (debuggingOptions.enableImpeller) '--enable-impeller',
];
final List<String> launchArguments = debuggingOptions.getIOSLaunchArguments(
EnvironmentType.physical,
route,
platformArgs,
);
final Status installStatus = _logger.startProgress(
'Installing and launching...',
);

View File

@@ -445,27 +445,11 @@ class IOSSimulator extends Device {
}
// Prepare launch arguments.
final String dartVmFlags = computeDartVmFlags(debuggingOptions);
final List<String> args = <String>[
'--enable-dart-profiling',
if (debuggingOptions.debuggingEnabled) ...<String>[
if (debuggingOptions.buildInfo.isDebug) ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',
if (debuggingOptions.startPaused) '--start-paused',
if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
if (debuggingOptions.useTestFonts) '--use-test-fonts',
if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"',
if (debuggingOptions.traceSkiaAllowlist != null) '--trace-skia-allowlist="${debuggingOptions.traceSkiaAllowlist}"',
if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags',
if (debuggingOptions.enableImpeller) '--enable-impeller',
'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}',
if (route != null) '--route=$route',
],
];
final List<String> launchArguments = debuggingOptions.getIOSLaunchArguments(
EnvironmentType.simulator,
route,
platformArgs,
);
ProtocolDiscovery? observatoryDiscovery;
if (debuggingOptions.debuggingEnabled) {
@@ -491,7 +475,7 @@ class IOSSimulator extends Device {
return LaunchResult.failed();
}
await _simControl.launch(id, bundleIdentifier, args);
await _simControl.launch(id, bundleIdentifier, launchArguments);
} on Exception catch (error) {
globals.printError('$error');
return LaunchResult.failed();

View File

@@ -172,7 +172,7 @@ class FlutterTesterDevice extends Device {
'--start-paused',
if (debuggingOptions.disableServiceAuthCodes)
'--disable-service-auth-codes',
if (debuggingOptions.hasObservatoryPort)
if (debuggingOptions.hostVmServicePort != null)
'--observatory-port=${debuggingOptions.hostVmServicePort}',
applicationKernelFilePath,
];