Unverified Commit 22bf19ce authored by Yuqian Li's avatar Yuqian Li Committed by GitHub

Add purge-persistent-cache option to run and drive (#62221)

Fixes https://github.com/flutter/flutter/issues/39526

Needs https://github.com/flutter/engine/pull/20013 to land and roll first.
parent 0c3b0c51
...@@ -654,6 +654,8 @@ class AndroidDevice extends Device { ...@@ -654,6 +654,8 @@ class AndroidDevice extends Device {
...<String>['--ez', 'dump-skp-on-shader-compilation', 'true'], ...<String>['--ez', 'dump-skp-on-shader-compilation', 'true'],
if (debuggingOptions.cacheSkSL) if (debuggingOptions.cacheSkSL)
...<String>['--ez', 'cache-sksl', 'true'], ...<String>['--ez', 'cache-sksl', 'true'],
if (debuggingOptions.purgePersistentCache)
...<String>['--ez', 'purge-persistent-cache', 'true'],
if (debuggingOptions.debuggingEnabled) ...<String>[ if (debuggingOptions.debuggingEnabled) ...<String>[
if (debuggingOptions.buildInfo.isDebug) ...<String>[ if (debuggingOptions.buildInfo.isDebug) ...<String>[
...<String>['--ez', 'enable-checked-mode', 'true'], ...<String>['--ez', 'enable-checked-mode', 'true'],
......
...@@ -493,6 +493,7 @@ Future<LaunchResult> _startApp( ...@@ -493,6 +493,7 @@ Future<LaunchResult> _startApp(
verboseSystemLogs: command.verboseSystemLogs, verboseSystemLogs: command.verboseSystemLogs,
cacheSkSL: command.cacheSkSL, cacheSkSL: command.cacheSkSL,
dumpSkpOnShaderCompilation: command.dumpSkpOnShaderCompilation, dumpSkpOnShaderCompilation: command.dumpSkpOnShaderCompilation,
purgePersistentCache: command.purgePersistentCache,
), ),
platformArgs: platformArgs, platformArgs: platformArgs,
prebuiltApplication: !command.shouldBuild, prebuiltApplication: !command.shouldBuild,
......
...@@ -52,6 +52,13 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -52,6 +52,13 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
'By default, this is not enabled to reduce the overhead. ' 'By default, this is not enabled to reduce the overhead. '
'This is only available in profile or debug build. ', 'This is only available in profile or debug build. ',
) )
..addFlag('purge-persistent-cache',
negatable: false,
help: 'Removes all existing persistent caches. This allows reproducing '
'shader compilation jank that normally only happens the first time '
'an app is run, or for reliable testing of compilation jank fixes '
'(e.g. shader warm-up).',
)
..addOption('route', ..addOption('route',
help: 'Which route to load when running the app.', help: 'Which route to load when running the app.',
) )
...@@ -74,6 +81,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -74,6 +81,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
bool get traceStartup => boolArg('trace-startup'); bool get traceStartup => boolArg('trace-startup');
bool get cacheSkSL => boolArg('cache-sksl'); bool get cacheSkSL => boolArg('cache-sksl');
bool get dumpSkpOnShaderCompilation => boolArg('dump-skp-on-shader-compilation'); bool get dumpSkpOnShaderCompilation => boolArg('dump-skp-on-shader-compilation');
bool get purgePersistentCache => boolArg('purge-persistent-cache');
String get route => stringArg('route'); String get route => stringArg('route');
} }
...@@ -397,6 +405,7 @@ class RunCommand extends RunCommandBase { ...@@ -397,6 +405,7 @@ class RunCommand extends RunCommandBase {
endlessTraceBuffer: boolArg('endless-trace-buffer'), endlessTraceBuffer: boolArg('endless-trace-buffer'),
dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation, dumpSkpOnShaderCompilation: dumpSkpOnShaderCompilation,
cacheSkSL: cacheSkSL, cacheSkSL: cacheSkSL,
purgePersistentCache: purgePersistentCache,
deviceVmServicePort: deviceVmservicePort, deviceVmServicePort: deviceVmservicePort,
hostVmServicePort: hostVmservicePort, hostVmServicePort: hostVmservicePort,
verboseSystemLogs: boolArg('verbose-system-logs'), verboseSystemLogs: boolArg('verbose-system-logs'),
......
...@@ -774,6 +774,7 @@ class DebuggingOptions { ...@@ -774,6 +774,7 @@ class DebuggingOptions {
this.endlessTraceBuffer = false, this.endlessTraceBuffer = false,
this.dumpSkpOnShaderCompilation = false, this.dumpSkpOnShaderCompilation = false,
this.cacheSkSL = false, this.cacheSkSL = false,
this.purgePersistentCache = false,
this.useTestFonts = false, this.useTestFonts = false,
this.verboseSystemLogs = false, this.verboseSystemLogs = false,
this.hostVmServicePort, this.hostVmServicePort,
...@@ -814,6 +815,7 @@ class DebuggingOptions { ...@@ -814,6 +815,7 @@ class DebuggingOptions {
traceSystrace = false, traceSystrace = false,
endlessTraceBuffer = false, endlessTraceBuffer = false,
dumpSkpOnShaderCompilation = false, dumpSkpOnShaderCompilation = false,
purgePersistentCache = false,
verboseSystemLogs = false, verboseSystemLogs = false,
hostVmServicePort = null, hostVmServicePort = null,
deviceVmServicePort = null, deviceVmServicePort = null,
...@@ -836,6 +838,7 @@ class DebuggingOptions { ...@@ -836,6 +838,7 @@ class DebuggingOptions {
final bool endlessTraceBuffer; final bool endlessTraceBuffer;
final bool dumpSkpOnShaderCompilation; final bool dumpSkpOnShaderCompilation;
final bool cacheSkSL; final bool cacheSkSL;
final bool purgePersistentCache;
final bool useTestFonts; final bool useTestFonts;
final bool verboseSystemLogs; final bool verboseSystemLogs;
/// Whether to invoke webOnlyInitializePlatform in Flutter for web. /// Whether to invoke webOnlyInitializePlatform in Flutter for web.
......
...@@ -383,6 +383,7 @@ class IOSDevice extends Device { ...@@ -383,6 +383,7 @@ class IOSDevice extends Device {
if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation', if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation',
if (debuggingOptions.verboseSystemLogs) '--verbose-logging', if (debuggingOptions.verboseSystemLogs) '--verbose-logging',
if (debuggingOptions.cacheSkSL) '--cache-sksl', if (debuggingOptions.cacheSkSL) '--cache-sksl',
if (debuggingOptions.purgePersistentCache) '--purge-persistent-cache',
if (platformArgs['trace-startup'] as bool ?? false) '--trace-startup', if (platformArgs['trace-startup'] as bool ?? false) '--trace-startup',
]; ];
......
...@@ -619,6 +619,11 @@ void main() { ...@@ -619,6 +619,11 @@ void main() {
'--cache-sksl', '--cache-sksl',
() => debuggingOptions.cacheSkSL, () => debuggingOptions.cacheSkSL,
); );
testOptionThatDefaultsToFalse(
'--purge-persistent-cache',
() => debuggingOptions.purgePersistentCache,
);
}); });
}); });
......
...@@ -249,6 +249,7 @@ void main() { ...@@ -249,6 +249,7 @@ void main() {
'--ez', 'endless-trace-buffer', 'true', '--ez', 'endless-trace-buffer', 'true',
'--ez', 'dump-skp-on-shader-compilation', 'true', '--ez', 'dump-skp-on-shader-compilation', 'true',
'--ez', 'cache-sksl', 'true', '--ez', 'cache-sksl', 'true',
'--ez', 'purge-persistent-cache', 'true',
'--ez', 'enable-checked-mode', 'true', '--ez', 'enable-checked-mode', 'true',
'--ez', 'verify-entry-points', 'true', '--ez', 'verify-entry-points', 'true',
'--ez', 'start-paused', 'true', '--ez', 'start-paused', 'true',
...@@ -277,6 +278,7 @@ void main() { ...@@ -277,6 +278,7 @@ void main() {
endlessTraceBuffer: true, endlessTraceBuffer: true,
dumpSkpOnShaderCompilation: true, dumpSkpOnShaderCompilation: true,
cacheSkSL: true, cacheSkSL: true,
purgePersistentCache: true,
useTestFonts: true, useTestFonts: true,
verboseSystemLogs: true, verboseSystemLogs: true,
), ),
......
...@@ -329,6 +329,7 @@ void main() { ...@@ -329,6 +329,7 @@ void main() {
'--dump-skp-on-shader-compilation', '--dump-skp-on-shader-compilation',
'--verbose-logging', '--verbose-logging',
'--cache-sksl', '--cache-sksl',
'--purge-persistent-cache',
].join(' '), ].join(' '),
], environment: const <String, String>{ ], environment: const <String, String>{
'PATH': '/usr/bin:null', 'PATH': '/usr/bin:null',
...@@ -382,6 +383,7 @@ void main() { ...@@ -382,6 +383,7 @@ void main() {
endlessTraceBuffer: true, endlessTraceBuffer: true,
dumpSkpOnShaderCompilation: true, dumpSkpOnShaderCompilation: true,
cacheSkSL: true, cacheSkSL: true,
purgePersistentCache: true,
verboseSystemLogs: true, verboseSystemLogs: true,
), ),
platformArgs: <String, dynamic>{}, platformArgs: <String, dynamic>{},
......
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