diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index ba146880d4..59b35ff851 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -143,6 +143,7 @@ TaskFunction createBackdropFilterPerfTest({ testDriver: 'test_driver/backdrop_filter_perf_test.dart', saveTraceFile: true, enableImpeller: enableImpeller, + disablePartialRepaint: true, ).run; } @@ -767,6 +768,51 @@ Map _average(List> results, int iterations return tally; } +/// Opens the file at testDirectory + 'ios/Runner/Info.plist' +/// and adds the following entry to the application. +/// +/// +void _disablePartialRepaint(String testDirectory) { + final String manifestPath = path.join( + testDirectory, 'ios', 'Runner', 'Info.plist'); + final File file = File(manifestPath); + + if (!file.existsSync()) { + throw Exception('Info.plist not found at $manifestPath'); + } + + final String xmlStr = file.readAsStringSync(); + final XmlDocument xmlDoc = XmlDocument.parse(xmlStr); + final List<(String, String)> keyPairs = <(String, String)>[ + ('FLTDisablePartialRepaint', 'true'), + ]; + + final XmlElement applicationNode = + xmlDoc.findAllElements('dict').first; + + // Check if the meta-data node already exists. + for (final (String key, String value) in keyPairs) { + applicationNode.children.add(XmlElement(XmlName('key'), [], [ + XmlText(key) + ], false)); + applicationNode.children.add(XmlElement(XmlName(value))); + } + + file.writeAsStringSync(xmlDoc.toXmlString(pretty: true, indent: ' ')); +} + +Future _resetPlist(String testDirectory) async { + final String manifestPath = path.join( + testDirectory, 'ios', 'Runner', 'Info.plist'); + final File file = File(manifestPath); + + if (!file.existsSync()) { + throw Exception('Info.plist not found at $manifestPath'); + } + + await exec('git', ['checkout', file.path]); +} + /// Opens the file at testDirectory + 'android/app/src/main/AndroidManifest.xml' /// and adds the following entry to the application. /// Function()? manifestReset; - if (forceOpenGLES ?? false) { - assert(enableImpeller!); - _addOpenGLESToManifest(testDirectory); - manifestReset = () => _resetManifest(testDirectory); + bool changedPlist = false; + bool changedManifest = false; + + Future resetManifest() async { + if (!changedManifest) { + return; + } + try { + await _resetManifest(testDirectory); + } catch (err) { + print('Caught exception while trying to reset AndroidManifest: $err'); + } + } + + Future resetPlist() async { + if (!changedPlist) { + return; + } + try { + await _resetPlist(testDirectory); + } catch (err) { + print('Caught exception while trying to reset Info.plist: $err'); + } } try { + if (forceOpenGLES ?? false) { + assert(enableImpeller!); + changedManifest = true; + _addOpenGLESToManifest(testDirectory); + } + if (disablePartialRepaint) { + changedPlist = true; + _disablePartialRepaint(testDirectory); + } + final List options = [ if (localEngine != null) ...['--local-engine', localEngine], if (localEngineHost != null) ...[ @@ -1278,9 +1357,8 @@ class PerfTest { await flutter('drive', options: options); } } finally { - if (manifestReset != null) { - await manifestReset(); - } + await resetManifest(); + await resetPlist(); } final Map data = json.decode(