Skip to content

Commit 925f3ee

Browse files
[benchmarks] disable partial repaint for multiple backdrop blur iOS macrobenchmarks. (#137902)
Partial repaint is too effective, and we'd like to be able to measure performance without carefully structuring the benchmarks. For example, right now partial repaint is culling any blurs in the multibackdrop case, which we should be using to track flutter/flutter#132735
1 parent f5a9835 commit 925f3ee

File tree

1 file changed

+86
-8
lines changed

1 file changed

+86
-8
lines changed

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ TaskFunction createBackdropFilterPerfTest({
143143
testDriver: 'test_driver/backdrop_filter_perf_test.dart',
144144
saveTraceFile: true,
145145
enableImpeller: enableImpeller,
146+
disablePartialRepaint: true,
146147
).run;
147148
}
148149

@@ -767,6 +768,51 @@ Map<String, dynamic> _average(List<Map<String, dynamic>> results, int iterations
767768
return tally;
768769
}
769770

771+
/// Opens the file at testDirectory + 'ios/Runner/Info.plist'
772+
/// and adds the following entry to the application.
773+
/// <FTLDisablePartialRepaint/>
774+
/// <true/>
775+
void _disablePartialRepaint(String testDirectory) {
776+
final String manifestPath = path.join(
777+
testDirectory, 'ios', 'Runner', 'Info.plist');
778+
final File file = File(manifestPath);
779+
780+
if (!file.existsSync()) {
781+
throw Exception('Info.plist not found at $manifestPath');
782+
}
783+
784+
final String xmlStr = file.readAsStringSync();
785+
final XmlDocument xmlDoc = XmlDocument.parse(xmlStr);
786+
final List<(String, String)> keyPairs = <(String, String)>[
787+
('FLTDisablePartialRepaint', 'true'),
788+
];
789+
790+
final XmlElement applicationNode =
791+
xmlDoc.findAllElements('dict').first;
792+
793+
// Check if the meta-data node already exists.
794+
for (final (String key, String value) in keyPairs) {
795+
applicationNode.children.add(XmlElement(XmlName('key'), <XmlAttribute>[], <XmlNode>[
796+
XmlText(key)
797+
], false));
798+
applicationNode.children.add(XmlElement(XmlName(value)));
799+
}
800+
801+
file.writeAsStringSync(xmlDoc.toXmlString(pretty: true, indent: ' '));
802+
}
803+
804+
Future<void> _resetPlist(String testDirectory) async {
805+
final String manifestPath = path.join(
806+
testDirectory, 'ios', 'Runner', 'Info.plist');
807+
final File file = File(manifestPath);
808+
809+
if (!file.existsSync()) {
810+
throw Exception('Info.plist not found at $manifestPath');
811+
}
812+
813+
await exec('git', <String>['checkout', file.path]);
814+
}
815+
770816
/// Opens the file at testDirectory + 'android/app/src/main/AndroidManifest.xml'
771817
/// and adds the following entry to the application.
772818
/// <meta-data
@@ -1124,6 +1170,7 @@ class PerfTest {
11241170
this.timeoutSeconds,
11251171
this.enableImpeller,
11261172
this.forceOpenGLES,
1173+
this.disablePartialRepaint = false,
11271174
}): _resultFilename = resultFilename;
11281175

11291176
const PerfTest.e2e(
@@ -1142,6 +1189,7 @@ class PerfTest {
11421189
this.timeoutSeconds,
11431190
this.enableImpeller,
11441191
this.forceOpenGLES,
1192+
this.disablePartialRepaint = false,
11451193
}) : saveTraceFile = false, timelineFileName = null, _resultFilename = resultFilename;
11461194

11471195
/// The directory where the app under test is defined.
@@ -1181,6 +1229,9 @@ class PerfTest {
11811229
/// Whether the perf test force Impeller's OpenGLES backend.
11821230
final bool? forceOpenGLES;
11831231

1232+
/// Whether partial repaint functionality should be disabled (iOS only).
1233+
final bool disablePartialRepaint;
1234+
11841235
/// Number of seconds to time out the test after, allowing debug callbacks to run.
11851236
final int? timeoutSeconds;
11861237

@@ -1230,14 +1281,42 @@ class PerfTest {
12301281
final String? localEngineHost = localEngineHostFromEnv;
12311282
final String? localEngineSrcPath = localEngineSrcPathFromEnv;
12321283

1233-
Future<void> Function()? manifestReset;
1234-
if (forceOpenGLES ?? false) {
1235-
assert(enableImpeller!);
1236-
_addOpenGLESToManifest(testDirectory);
1237-
manifestReset = () => _resetManifest(testDirectory);
1284+
bool changedPlist = false;
1285+
bool changedManifest = false;
1286+
1287+
Future<void> resetManifest() async {
1288+
if (!changedManifest) {
1289+
return;
1290+
}
1291+
try {
1292+
await _resetManifest(testDirectory);
1293+
} catch (err) {
1294+
print('Caught exception while trying to reset AndroidManifest: $err');
1295+
}
1296+
}
1297+
1298+
Future<void> resetPlist() async {
1299+
if (!changedPlist) {
1300+
return;
1301+
}
1302+
try {
1303+
await _resetPlist(testDirectory);
1304+
} catch (err) {
1305+
print('Caught exception while trying to reset Info.plist: $err');
1306+
}
12381307
}
12391308

12401309
try {
1310+
if (forceOpenGLES ?? false) {
1311+
assert(enableImpeller!);
1312+
changedManifest = true;
1313+
_addOpenGLESToManifest(testDirectory);
1314+
}
1315+
if (disablePartialRepaint) {
1316+
changedPlist = true;
1317+
_disablePartialRepaint(testDirectory);
1318+
}
1319+
12411320
final List<String> options = <String>[
12421321
if (localEngine != null) ...<String>['--local-engine', localEngine],
12431322
if (localEngineHost != null) ...<String>[
@@ -1278,9 +1357,8 @@ class PerfTest {
12781357
await flutter('drive', options: options);
12791358
}
12801359
} finally {
1281-
if (manifestReset != null) {
1282-
await manifestReset();
1283-
}
1360+
await resetManifest();
1361+
await resetPlist();
12841362
}
12851363

12861364
final Map<String, dynamic> data = json.decode(

0 commit comments

Comments
 (0)