Unverified Commit c663cd55 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

[flutter_tools] Refresh VM state before executing hot reload (#53960)

parent cccfe96e
...@@ -825,6 +825,13 @@ abstract class ResidentRunner { ...@@ -825,6 +825,13 @@ abstract class ResidentRunner {
await Future.wait(futures); await Future.wait(futures);
} }
Future<void> refreshVM() async {
final List<Future<void>> futures = <Future<void>>[
for (final FlutterDevice device in flutterDevices) device.getVMs(),
];
await Future.wait(futures);
}
Future<void> debugDumpApp() async { Future<void> debugDumpApp() async {
await refreshViews(); await refreshViews();
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
......
...@@ -798,6 +798,7 @@ class HotRunner extends ResidentRunner { ...@@ -798,6 +798,7 @@ class HotRunner extends ResidentRunner {
if (!_isPaused()) { if (!_isPaused()) {
globals.printTrace('Refreshing active FlutterViews before reloading.'); globals.printTrace('Refreshing active FlutterViews before reloading.');
await refreshVM();
await refreshViews(); await refreshViews();
} }
......
...@@ -111,6 +111,7 @@ void main() { ...@@ -111,6 +111,7 @@ void main() {
}); });
when(mockFlutterDevice.vmService).thenReturn(mockVMService); when(mockFlutterDevice.vmService).thenReturn(mockVMService);
when(mockFlutterDevice.refreshViews()).thenAnswer((Invocation invocation) async { }); when(mockFlutterDevice.refreshViews()).thenAnswer((Invocation invocation) async { });
when(mockFlutterDevice.getVMs()).thenAnswer((Invocation invocation) async { });
when(mockFlutterDevice.reloadSources(any, pause: anyNamed('pause'))).thenReturn(<Future<Map<String, dynamic>>>[ when(mockFlutterDevice.reloadSources(any, pause: anyNamed('pause'))).thenReturn(<Future<Map<String, dynamic>>>[
Future<Map<String, dynamic>>.value(<String, dynamic>{ Future<Map<String, dynamic>>.value(<String, dynamic>{
'type': 'ReloadReport', 'type': 'ReloadReport',
......
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