Unverified Commit 707aa49e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] flush UI thread tasks before finishing hot restart (#66417)

Improve our ability to measure the performance of hot restart. Also flush all UI thread tasks before calling the hot restart "complete" in benchmark mode.

If this is successful at stabilizing the benchmarks, this should be enabled for "normal" hot restart so that we can accurately track execution time.
parent f6543467
......@@ -554,7 +554,11 @@ class HotRunner extends ResidentRunner {
.catchError((dynamic error, StackTrace stackTrace) {
// Do nothing on a SentinelException since it means the isolate
// has already been killed.
}, test: (dynamic error) => error is vm_service.SentinelException));
// Error code 105 indicates the isolate is not yet runnable, and might
// be triggered if the tool is attempting to kill the asset parsing
// isolate before it has finished starting up.
}, test: (dynamic error) => error is vm_service.SentinelException
|| (error is vm_service.RPCError && error.code == 105)));
}
}
await Future.wait(operations);
......@@ -568,7 +572,6 @@ class HotRunner extends ResidentRunner {
// Send timing analytics.
globals.flutterUsage.sendTiming('hot', 'restart', restartTimer.elapsed);
// In benchmark mode, make sure all stream notifications have finished.
if (benchmarkMode) {
final List<Future<void>> isolateNotifications = <Future<void>>[];
for (final FlutterDevice device in flutterDevices) {
......@@ -584,7 +587,17 @@ class HotRunner extends ResidentRunner {
);
}
await Future.wait(isolateNotifications);
final List<Future<void>> futures = <Future<void>>[];
for (final FlutterDevice device in flutterDevices) {
final List<FlutterView> views = await device.vmService.getFlutterViews();
for (final FlutterView view in views) {
futures.add(device.vmService
.flushUIThreadTasks(uiIsolateId: view.uiIsolate.id));
}
}
await Future.wait(futures);
}
// Toggle the main dill name after successfully uploading.
_swap =! _swap;
......
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