Skip to content

Commit 499c84c

Browse files
authored
Fix flaky complex_layout_scroll_perf__memory test (#150287)
Initial tap is missing sometimes; either its never delivered or it is delivered before gesture controller is hooked up. 1: Update the two perf tests to output when TAPPED is received 2: Update the MemoryTest to keep tapping while waiting for TAPPED Tested on devicelab: * setting iterations=1 * removing the timeout before READY * running tests in a while loop Before this change, you could get the test to hang often. After this change you'll see "tapping device... [x]" where x is the counter. Fixes #150096
1 parent 1c77696 commit 499c84c

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

dev/benchmarks/complex_layout/test_memory/scroll_perf.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Future<void> main() async {
2323
final Completer<void> ready = Completer<void>();
2424
runApp(GestureDetector(
2525
onTap: () {
26-
debugPrint('Received tap.');
26+
debugPrint('==== MEMORY BENCHMARK ==== TAPPED ====');
2727
ready.complete();
2828
},
2929
behavior: HitTestBehavior.opaque,
@@ -32,16 +32,14 @@ Future<void> main() async {
3232
),
3333
));
3434
await SchedulerBinding.instance.endOfFrame;
35-
36-
/// Wait 50ms to allow the raster thread to actually put up the frame. (The
37-
/// endOfFrame future ends when we send the data to the engine, before
38-
/// the raster thread has had a chance to rasterize, etc.)
39-
await Future<void>.delayed(const Duration(milliseconds: 50));
4035
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
4136

4237
await ready.future; // waits for tap sent by devicelab task
4338
debugPrint('Continuing...');
4439

40+
// Wait out any errant taps due to synchronization
41+
await Future<void>.delayed(const Duration(milliseconds: 200));
42+
4543
// remove onTap handler, enable pointer events for app
4644
runApp(GestureDetector(
4745
child: const IgnorePointer(

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,9 +2071,34 @@ class MemoryTest {
20712071
await launchApp();
20722072
await recordStart();
20732073

2074+
// Keep "tapping" the device till it responds with the string we expect,
2075+
// or throw an error instead of tying up the infrastructure for 30 minutes.
2076+
prepareForNextMessage('TAPPED');
2077+
bool tapped = false;
2078+
int tapCount = 0;
2079+
await Future.any(<Future<void>>[
2080+
() async {
2081+
while (true) {
2082+
if (tapped) {
2083+
break;
2084+
}
2085+
tapCount += 1;
2086+
print('tapping device... [$tapCount]');
2087+
await device!.tap(100, 100);
2088+
await Future<void>.delayed(const Duration(milliseconds: 100));
2089+
}
2090+
}(),
2091+
() async {
2092+
print('awaiting "tapped" message... (timeout: 10 seconds)');
2093+
try {
2094+
await receivedNextMessage?.timeout(const Duration(seconds: 10));
2095+
} finally {
2096+
tapped = true;
2097+
}
2098+
}(),
2099+
]);
2100+
20742101
prepareForNextMessage('DONE');
2075-
print('tapping device...');
2076-
await device!.tap(100, 100);
20772102
print('awaiting "done" message...');
20782103
await receivedNextMessage;
20792104

dev/integration_tests/flutter_gallery/test_memory/memory_nav.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Future<void> main() async {
2626
final Completer<void> ready = Completer<void>();
2727
runApp(GestureDetector(
2828
onTap: () {
29-
debugPrint('Received tap.');
29+
debugPrint('==== MEMORY BENCHMARK ==== TAPPED ====');
3030
ready.complete();
3131
},
3232
behavior: HitTestBehavior.opaque,
@@ -35,12 +35,14 @@ Future<void> main() async {
3535
),
3636
));
3737
await SchedulerBinding.instance.endOfFrame;
38-
await Future<void>.delayed(const Duration(milliseconds: 50));
3938
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
4039

4140
await ready.future;
4241
debugPrint('Continuing...');
4342

43+
// Wait out any errant taps due to synchronization
44+
await Future<void>.delayed(const Duration(milliseconds: 200));
45+
4446
// remove onTap handler, enable pointer events for app
4547
runApp(GestureDetector(
4648
child: const IgnorePointer(

0 commit comments

Comments
 (0)