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

This commit is contained in:
Jason Simmons 2020-04-07 15:41:02 -07:00 committed by GitHub
parent cccfe96e72
commit c663cd55a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -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) {

View File

@ -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();
} }

View File

@ -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',