Unverified Commit 6990b8b2 authored by gaaclarke's avatar gaaclarke Committed by GitHub

Added the "trace-whitelist" flag to run. (#52556)

parent f149eec3
......@@ -584,6 +584,8 @@ class AndroidDevice extends Device {
...<String>['--ez', 'skia-deterministic-rendering', 'true'],
if (debuggingOptions.traceSkia)
...<String>['--ez', 'trace-skia', 'true'],
if (debuggingOptions.traceWhitelist != null)
...<String>['--ez', 'trace-whitelist', debuggingOptions.traceWhitelist],
if (debuggingOptions.traceSystrace)
...<String>['--ez', 'trace-systrace', 'true'],
if (debuggingOptions.endlessTraceBuffer)
......
......@@ -102,6 +102,11 @@ class RunCommand extends RunCommandBase {
help: 'Enable tracing of Skia code. This is useful when debugging '
'the GPU thread. By default, Flutter will not log skia code.',
)
..addOption('trace-whitelist',
help: 'Filters out all trace events except those that are specified in '
'this comma separated list of whitelisted prefixes.',
valueHelp: 'foo,bar',
)
..addFlag('endless-trace-buffer',
negatable: false,
help: 'Enable tracing to the endless tracer. This is useful when '
......@@ -360,6 +365,7 @@ class RunCommand extends RunCommandBase {
enableSoftwareRendering: boolArg('enable-software-rendering'),
skiaDeterministicRendering: boolArg('skia-deterministic-rendering'),
traceSkia: boolArg('trace-skia'),
traceWhitelist: stringArg('trace-whitelist'),
traceSystrace: boolArg('trace-systrace'),
endlessTraceBuffer: boolArg('endless-trace-buffer'),
dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation,
......
......@@ -550,6 +550,7 @@ class DebuggingOptions {
this.enableSoftwareRendering = false,
this.skiaDeterministicRendering = false,
this.traceSkia = false,
this.traceWhitelist,
this.traceSystrace = false,
this.endlessTraceBuffer = false,
this.dumpSkpOnShaderCompilation = false,
......@@ -576,6 +577,7 @@ class DebuggingOptions {
this.webRunHeadless = false,
this.webBrowserDebugPort,
this.cacheSkSL = false,
this.traceWhitelist,
}) : debuggingEnabled = false,
useTestFonts = false,
startPaused = false,
......@@ -602,6 +604,7 @@ class DebuggingOptions {
final bool enableSoftwareRendering;
final bool skiaDeterministicRendering;
final bool traceSkia;
final String traceWhitelist;
final bool traceSystrace;
final bool endlessTraceBuffer;
final bool dumpSkpOnShaderCompilation;
......
......@@ -273,6 +273,7 @@ class IOSDevice extends Device {
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
if (debuggingOptions.traceSkia) '--trace-skia',
if (debuggingOptions.traceWhitelist != null) '--trace-whitelist="${debuggingOptions.traceWhitelist}"',
if (debuggingOptions.endlessTraceBuffer) '--endless-trace-buffer',
if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation',
if (debuggingOptions.verboseSystemLogs) '--verbose-logging',
......
......@@ -405,6 +405,7 @@ class IOSSimulator extends Device {
if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
if (debuggingOptions.useTestFonts) '--use-test-fonts',
if (debuggingOptions.traceWhitelist != null) '--trace-whitelist="${debuggingOptions.traceWhitelist}"',
'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}',
],
];
......
......@@ -64,38 +64,46 @@ void main() {
mockAndroidSdk = MockAndroidSdk();
});
testUsingContext('succeeds with --cache-sksl', () async {
const String deviceId = '1234';
final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
final File adbExe = globals.fs.file(getAdbPath(androidSdk));
void _setupMockAndroidSdk(AndroidSdk mockAndroidSdk) {
when(mockAndroidSdk.licensesAvailable).thenReturn(true);
when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion());
}
void _setupMockProcessManager(ProcessManager mockProcessManager,
String deviceId, ProcessResult getPropResult) {
final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockProcessManager.run(
<String>[adbExe.path, '-s', deviceId, 'shell', 'getprop'],
stdoutEncoding: latin1,
stderrEncoding: latin1,
)).thenAnswer((_) async {
return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', '');
return getPropResult;
});
when(mockProcessManager.run(
any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')
)).thenAnswer((_) async {
when(mockProcessManager.run(any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')))
.thenAnswer((_) async {
return ProcessResult(0, 0, '', '');
});
when(mockProcessManager.start(
any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')
)).thenAnswer((_) async {
when(mockProcessManager.start(any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')))
.thenAnswer((_) async {
return FakeProcess();
});
}
testUsingContext('succeeds with --cache-sksl', () async {
const String deviceId = '1234';
final AndroidDevice device =
AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
_setupMockAndroidSdk(mockAndroidSdk);
_setupMockProcessManager(mockProcessManager, deviceId,
ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', ''));
final LaunchResult launchResult = await device.startApp(
mockApk,
......@@ -108,8 +116,9 @@ void main() {
);
expect(launchResult.started, isTrue);
expect(verify(mockProcessManager.run(captureAny)).captured.last.join(','),
contains(<String>['--ez', 'cache-sksl', 'true'].join(',')));
expect(
verify(mockProcessManager.run(captureAny)).captured.last.join(','),
contains(<String>['--ez', 'cache-sksl', 'true'].join(',')));
}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
FileSystem: () => MemoryFileSystem(),
......@@ -118,36 +127,15 @@ void main() {
testUsingContext('can run a release build on x64', () async {
const String deviceId = '1234';
final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
final AndroidDevice device =
AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockAndroidSdk.licensesAvailable).thenReturn(true);
when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion());
when(mockProcessManager.run(
<String>[adbExe.path, '-s', deviceId, 'shell', 'getprop'],
stdoutEncoding: latin1,
stderrEncoding: latin1,
)).thenAnswer((_) async {
return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]\n[ro.product.cpu.abi]: [x86_64]', '');
});
when(mockProcessManager.run(
any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')
)).thenAnswer((_) async {
return ProcessResult(0, 0, '', '');
});
when(mockProcessManager.start(
any,
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment')
)).thenAnswer((_) async {
return FakeProcess();
});
_setupMockAndroidSdk(mockAndroidSdk);
_setupMockProcessManager(mockProcessManager, deviceId,
ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', ''));
final LaunchResult launchResult = await device.startApp(
mockApk,
......@@ -163,6 +151,38 @@ void main() {
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
});
testUsingContext('test trace whitelist flag', () async {
const String deviceId = '1234';
final AndroidDevice device =
AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
_setupMockAndroidSdk(mockAndroidSdk);
_setupMockProcessManager(mockProcessManager, deviceId,
ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', ''));
final LaunchResult launchResult = await device.startApp(
mockApk,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.disabled(
const BuildInfo(BuildMode.profile, null, treeShakeIcons: false),
traceWhitelist: 'foo',
),
platformArgs: <String, dynamic>{},
);
expect(launchResult.started, isTrue);
expect(
verify(mockProcessManager.run(captureAny)).captured.last.join(','),
contains(<String>['--ez', 'trace-whitelist', 'foo'].join(',')));
}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
});
});
});
......
......@@ -677,6 +677,43 @@ void main() {
expect(await device.stopApp(mockApp), isFalse);
});
testUsingContext('trace whitelist flags', () async {
final IOSDevice device = IOSDevice(
'123',
name: 'iPhone 1',
fileSystem: mockFileSystem,
sdkVersion: '13.3',
cpuArchitecture: DarwinArch.arm64,
platform: mockPlatform,
artifacts: mockArtifacts,
iosDeploy: mockIosDeploy,
);
when(mockIosDeploy.installApp(
deviceId: device.id,
bundlePath: anyNamed('bundlePath'),
launchArguments: <String>[],
)).thenAnswer((Invocation invocation) => Future<int>.value(0));
when(mockIosDeploy.runApp(
deviceId: device.id,
bundlePath: anyNamed('bundlePath'),
launchArguments: anyNamed('launchArguments'),
)).thenAnswer((Invocation invocation) => Future<int>.value(0));
await device.startApp(mockApp,
prebuiltApplication: true,
debuggingOptions: DebuggingOptions.disabled(
const BuildInfo(BuildMode.release, null, treeShakeIcons: false),
traceWhitelist: 'foo'),
platformArgs: <String, dynamic>{},
);
final VerificationResult toVerify = verify(mockIosDeploy.runApp(
deviceId: device.id,
bundlePath: anyNamed('bundlePath'),
launchArguments: captureAnyNamed('launchArguments'),
));
expect(toVerify.captured[0], contains('--trace-whitelist="foo"'));
await device.stopApp(mockApp);
});
testUsingContext('succeeds with --cache-sksl', () async {
final IOSDevice device = IOSDevice(
'123',
......
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