Unverified Commit 3300a1bd authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] eagerly set asset directory path, cache flutter views,...

[flutter_tools] eagerly set asset directory path, cache flutter views, simplify error handling (#68978)

Performs some small cleanup on the hot reload code path.

- Combines nested try/catch into single try catch, update on clause now that package:vm_service is used and Map does not need to be caught.
- Cache FlutterViews for the lifetime of the hot reload method handler
- Set asset directory path once during startup and remove conditional set during hot reload
parent 95563ff1
...@@ -110,7 +110,6 @@ class HotRunner extends ResidentRunner { ...@@ -110,7 +110,6 @@ class HotRunner extends ResidentRunner {
final Map<String, List<int>> benchmarkData = <String, List<int>>{}; final Map<String, List<int>> benchmarkData = <String, List<int>>{};
DateTime firstBuildTime; DateTime firstBuildTime;
bool _shouldResetAssetDirectory = true;
void _addBenchmarkData(String name, int value) { void _addBenchmarkData(String name, int value) {
benchmarkData[name] ??= <int>[]; benchmarkData[name] ??= <int>[];
...@@ -205,7 +204,7 @@ class HotRunner extends ResidentRunner { ...@@ -205,7 +204,7 @@ class HotRunner extends ResidentRunner {
), ),
); );
} }
} on Exception catch (error) { } on DevFSException catch (error) {
globals.printError('Error initializing DevFS: $error'); globals.printError('Error initializing DevFS: $error');
return 3; return 3;
} }
...@@ -226,6 +225,14 @@ class HotRunner extends ResidentRunner { ...@@ -226,6 +225,14 @@ class HotRunner extends ResidentRunner {
device.generator.accept(); device.generator.accept();
} }
final List<FlutterView> views = await device.vmService.getFlutterViews(); final List<FlutterView> views = await device.vmService.getFlutterViews();
final Uri deviceAssetsDirectoryUri = device.devFS.baseUri.resolveUri(globals.fs.path.toUri(getAssetBuildDirectory()));
await Future.wait<void>(views.map<Future<void>>(
(FlutterView view) => device.vmService.setAssetDirectory(
assetsDirectory: deviceAssetsDirectoryUri,
uiIsolateId: view.uiIsolate.id,
viewId: view.id,
)
));
for (final FlutterView view in views) { for (final FlutterView view in views) {
globals.printTrace('Connected to $view.'); globals.printTrace('Connected to $view.');
} }
...@@ -729,17 +736,36 @@ class HotRunner extends ResidentRunner { ...@@ -729,17 +736,36 @@ class HotRunner extends ResidentRunner {
); );
}, },
); );
} on vm_service.RPCError { } on vm_service.RPCError catch (error) {
HotEvent('exception', String errorMessage = 'hot reload failed to complete';
targetPlatform: targetPlatform, int errorCode = 1;
sdkName: sdkName, if (error.code == kIsolateReloadBarred) {
emulator: emulator, errorCode = error.code;
fullRestart: false, errorMessage = 'Unable to hot reload application due to an unrecoverable error in '
nullSafety: usageNullSafety, 'the source code. Please address the error and then use "R" to '
reason: reason, 'restart the app.\n'
fastReassemble: null, '${error.message} (error code: ${error.code})';
).send(); HotEvent('reload-barred',
return OperationResult(1, 'hot reload failed to complete', fatal: true); targetPlatform: targetPlatform,
sdkName: sdkName,
emulator: emulator,
fullRestart: false,
reason: reason,
nullSafety: usageNullSafety,
fastReassemble: null,
).send();
} else {
HotEvent('exception',
targetPlatform: targetPlatform,
sdkName: sdkName,
emulator: emulator,
fullRestart: false,
nullSafety: usageNullSafety,
reason: reason,
fastReassemble: null,
).send();
}
return OperationResult(errorCode, errorMessage, fatal: true);
} finally { } finally {
status.cancel(); status.cancel();
} }
...@@ -764,20 +790,6 @@ class HotRunner extends ResidentRunner { ...@@ -764,20 +790,6 @@ class HotRunner extends ResidentRunner {
]; ];
} }
Future<void> _resetAssetDirectory(FlutterDevice device) async {
final Uri deviceAssetsDirectoryUri = device.devFS.baseUri.resolveUri(
globals.fs.path.toUri(getAssetBuildDirectory()));
assert(deviceAssetsDirectoryUri != null);
final List<FlutterView> views = await device.vmService.getFlutterViews();
await Future.wait<void>(views.map<Future<void>>(
(FlutterView view) => device.vmService.setAssetDirectory(
assetsDirectory: deviceAssetsDirectoryUri,
uiIsolateId: view.uiIsolate.id,
viewId: view.id,
)
));
}
Future<OperationResult> _reloadSources({ Future<OperationResult> _reloadSources({
String targetPlatform, String targetPlatform,
String sdkName, String sdkName,
...@@ -786,8 +798,10 @@ class HotRunner extends ResidentRunner { ...@@ -786,8 +798,10 @@ class HotRunner extends ResidentRunner {
String reason, String reason,
void Function(String message) onSlow, void Function(String message) onSlow,
}) async { }) async {
final Map<FlutterDevice, List<FlutterView>> viewCache = <FlutterDevice, List<FlutterView>>{};
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
final List<FlutterView> views = await device.vmService.getFlutterViews(); final List<FlutterView> views = await device.vmService.getFlutterViews();
viewCache[device] = views;
for (final FlutterView view in views) { for (final FlutterView view in views) {
if (view.uiIsolate == null) { if (view.uiIsolate == null) {
return OperationResult(2, 'Application isolate not found', fatal: true); return OperationResult(2, 'Application isolate not found', fatal: true);
...@@ -806,74 +820,36 @@ class HotRunner extends ResidentRunner { ...@@ -806,74 +820,36 @@ class HotRunner extends ResidentRunner {
} }
String reloadMessage; String reloadMessage;
final Stopwatch vmReloadTimer = Stopwatch()..start(); final Stopwatch vmReloadTimer = Stopwatch()..start();
Map<String, dynamic> firstReloadDetails; Map<String, Object> firstReloadDetails;
try { const String entryPath = 'main.dart.incremental.dill';
const String entryPath = 'main.dart.incremental.dill'; final List<Future<DeviceReloadReport>> allReportsFutures = <Future<DeviceReloadReport>>[];
final List<Future<DeviceReloadReport>> allReportsFutures = <Future<DeviceReloadReport>>[];
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
if (_shouldResetAssetDirectory) { final List<Future<vm_service.ReloadReport>> reportFutures = await _reloadDeviceSources(
// Asset directory has to be set only once when the engine switches from device,
// running from bundle to uploaded files. entryPath,
await _resetAssetDirectory(device); pause: pause,
_shouldResetAssetDirectory = false; );
} allReportsFutures.add(Future.wait(reportFutures).then(
final List<Future<vm_service.ReloadReport>> reportFutures = await _reloadDeviceSources( (List<vm_service.ReloadReport> reports) async {
device, // TODO(aam): Investigate why we are validating only first reload report,
entryPath, pause: pause, // which seems to be current behavior
); final vm_service.ReloadReport firstReport = reports.first;
allReportsFutures.add(Future.wait(reportFutures).then( // Don't print errors because they will be printed further down when
(List<vm_service.ReloadReport> reports) async { // `validateReloadReport` is called again.
// TODO(aam): Investigate why we are validating only first reload report, await device.updateReloadStatus(
// which seems to be current behavior validateReloadReport(firstReport, printErrors: false),
final vm_service.ReloadReport firstReport = reports.first; );
// Don't print errors because they will be printed further down when return DeviceReloadReport(device, reports);
// `validateReloadReport` is called again. },
await device.updateReloadStatus( ));
validateReloadReport(firstReport, printErrors: false), }
); final List<DeviceReloadReport> reports = await Future.wait(allReportsFutures);
return DeviceReloadReport(device, reports); for (final DeviceReloadReport report in reports) {
}, final vm_service.ReloadReport reloadReport = report.reports[0];
)); if (!validateReloadReport(reloadReport)) {
} // Reload failed.
final List<DeviceReloadReport> reports = await Future.wait(allReportsFutures); HotEvent('reload-reject',
for (final DeviceReloadReport report in reports) {
final vm_service.ReloadReport reloadReport = report.reports[0];
if (!validateReloadReport(reloadReport)) {
// Reload failed.
HotEvent('reload-reject',
targetPlatform: targetPlatform,
sdkName: sdkName,
emulator: emulator,
fullRestart: false,
reason: reason,
nullSafety: usageNullSafety,
fastReassemble: null,
).send();
// Reset devFS lastCompileTime to ensure the file will still be marked
// as dirty on subsequent reloads.
_resetDevFSCompileTime();
final ReloadReportContents contents = ReloadReportContents.fromReloadReport(reloadReport);
return OperationResult(1, 'Reload rejected: ${contents.notices.join("\n")}');
}
// Collect stats only from the first device. If/when run -d all is
// refactored, we'll probably need to send one hot reload/restart event
// per device to analytics.
firstReloadDetails ??= castStringKeyedMap(reloadReport.json['details']);
final int loadedLibraryCount = reloadReport.json['details']['loadedLibraryCount'] as int;
final int finalLibraryCount = reloadReport.json['details']['finalLibraryCount'] as int;
globals.printTrace('reloaded $loadedLibraryCount of $finalLibraryCount libraries');
reloadMessage = 'Reloaded $loadedLibraryCount of $finalLibraryCount libraries';
}
} on Map<String, dynamic> catch (error, stackTrace) {
globals.printTrace('Hot reload failed: $error\n$stackTrace');
final int errorCode = error['code'] as int;
String errorMessage = error['message'] as String;
if (errorCode == kIsolateReloadBarred) {
errorMessage = 'Unable to hot reload application due to an unrecoverable error in '
'the source code. Please address the error and then use "R" to '
'restart the app.\n'
'$errorMessage (error code: $errorCode)';
HotEvent('reload-barred',
targetPlatform: targetPlatform, targetPlatform: targetPlatform,
sdkName: sdkName, sdkName: sdkName,
emulator: emulator, emulator: emulator,
...@@ -882,27 +858,35 @@ class HotRunner extends ResidentRunner { ...@@ -882,27 +858,35 @@ class HotRunner extends ResidentRunner {
nullSafety: usageNullSafety, nullSafety: usageNullSafety,
fastReassemble: null, fastReassemble: null,
).send(); ).send();
return OperationResult(errorCode, errorMessage); // Reset devFS lastCompileTime to ensure the file will still be marked
// as dirty on subsequent reloads.
_resetDevFSCompileTime();
final ReloadReportContents contents = ReloadReportContents.fromReloadReport(reloadReport);
return OperationResult(1, 'Reload rejected: ${contents.notices.join("\n")}');
} }
return OperationResult(errorCode, '$errorMessage (error code: $errorCode)'); // Collect stats only from the first device. If/when run -d all is
} on Exception catch (error, stackTrace) { // refactored, we'll probably need to send one hot reload/restart event
globals.printTrace('Hot reload failed: $error\n$stackTrace'); // per device to analytics.
return OperationResult(1, '$error'); firstReloadDetails ??= castStringKeyedMap(reloadReport.json['details']);
final int loadedLibraryCount = reloadReport.json['details']['loadedLibraryCount'] as int;
final int finalLibraryCount = reloadReport.json['details']['finalLibraryCount'] as int;
globals.printTrace('reloaded $loadedLibraryCount of $finalLibraryCount libraries');
reloadMessage = 'Reloaded $loadedLibraryCount of $finalLibraryCount libraries';
} }
// Record time it took for the VM to reload the sources. // Record time it took for the VM to reload the sources.
_addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds); _addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds);
final Stopwatch reassembleTimer = Stopwatch()..start(); final Stopwatch reassembleTimer = Stopwatch()..start();
await _evictDirtyAssets(); await _evictDirtyAssets();
// Check if any isolates are paused and reassemble those // Check if any isolates are paused and reassemble those that aren't.
// that aren't.
final Map<FlutterView, vm_service.VmService> reassembleViews = <FlutterView, vm_service.VmService>{}; final Map<FlutterView, vm_service.VmService> reassembleViews = <FlutterView, vm_service.VmService>{};
final List<Future<void>> reassembleFutures = <Future<void>>[]; final List<Future<void>> reassembleFutures = <Future<void>>[];
String serviceEventKind; String serviceEventKind;
int pausedIsolatesFound = 0; int pausedIsolatesFound = 0;
bool failedReassemble = false; bool failedReassemble = false;
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
final List<FlutterView> views = await device.vmService.getFlutterViews(); final List<FlutterView> views = viewCache[device];
for (final FlutterView view in views) { for (final FlutterView view in views) {
// Check if the isolate is paused, and if so, don't reassemble. Ignore the // Check if the isolate is paused, and if so, don't reassemble. Ignore the
// PostPauseEvent event - the client requesting the pause will resume the app. // PostPauseEvent event - the client requesting the pause will resume the app.
......
...@@ -112,6 +112,15 @@ final FakeVmServiceRequest listViews = FakeVmServiceRequest( ...@@ -112,6 +112,15 @@ final FakeVmServiceRequest listViews = FakeVmServiceRequest(
}, },
); );
const FakeVmServiceRequest setAssetBundlePath = FakeVmServiceRequest(
method: '_flutter.setAssetBundlePath',
args: <String, Object>{
'viewId': 'a',
'assetDirectory': 'build/flutter_assets',
'isolateId': '1',
}
);
void main() { void main() {
final Uri testUri = Uri.parse('foo://bar'); final Uri testUri = Uri.parse('foo://bar');
Testbed testbed; Testbed testbed;
...@@ -168,7 +177,7 @@ void main() { ...@@ -168,7 +177,7 @@ void main() {
return UpdateFSReport( return UpdateFSReport(
success: true, success: true,
syncedBytes: 0, syncedBytes: 0,
invalidatedSourcesCount: 0, invalidatedSourcesCount: 1,
); );
}); });
when(mockFlutterDevice.devFS).thenReturn(mockDevFS); when(mockFlutterDevice.devFS).thenReturn(mockDevFS);
...@@ -194,6 +203,7 @@ void main() { ...@@ -194,6 +203,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync(); final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync();
final Completer<void> onAppStart = Completer<void>.sync(); final Completer<void> onAppStart = Completer<void>.sync();
...@@ -219,6 +229,7 @@ void main() { ...@@ -219,6 +229,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
final MockResidentCompiler residentCompiler = MockResidentCompiler(); final MockResidentCompiler residentCompiler = MockResidentCompiler();
residentRunner = HotRunner( residentRunner = HotRunner(
...@@ -345,6 +356,7 @@ void main() { ...@@ -345,6 +356,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
final MockResidentCompiler residentCompiler = MockResidentCompiler(); final MockResidentCompiler residentCompiler = MockResidentCompiler();
residentRunner = HotRunner( residentRunner = HotRunner(
...@@ -387,6 +399,7 @@ void main() { ...@@ -387,6 +399,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
...@@ -465,6 +478,7 @@ void main() { ...@@ -465,6 +478,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
listViews, listViews,
]); ]);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async { when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
...@@ -514,10 +528,66 @@ void main() { ...@@ -514,10 +528,66 @@ void main() {
Usage: () => MockUsage(), Usage: () => MockUsage(),
})); }));
testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,
listViews,
setAssetBundlePath,
listViews,
]);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
return 'Example';
});
when(mockDevice.targetPlatform).thenAnswer((Invocation invocation) async {
return TargetPlatform.android_arm;
});
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) async {
return false;
});
final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync();
final Completer<void> onAppStart = Completer<void>.sync();
unawaited(residentRunner.attach(
appStartedCompleter: onAppStart,
connectionInfoCompleter: onConnectionInfo,
));
await onAppStart.future;
when(mockFlutterDevice.updateDevFS(
mainUri: anyNamed('mainUri'),
target: anyNamed('target'),
bundle: anyNamed('bundle'),
firstBuildTime: anyNamed('firstBuildTime'),
bundleFirstUpload: anyNamed('bundleFirstUpload'),
bundleDirty: anyNamed('bundleDirty'),
fullRestart: anyNamed('fullRestart'),
projectRootPath: anyNamed('projectRootPath'),
pathToReload: anyNamed('pathToReload'),
invalidatedFiles: anyNamed('invalidatedFiles'),
dillOutputPath: anyNamed('dillOutputPath'),
packageConfig: anyNamed('packageConfig'),
)).thenThrow(vm_service.RPCError('something bad happened', kIsolateReloadBarred, ''));
final OperationResult result = await residentRunner.restart(fullRestart: false);
expect(result.fatal, true);
expect(result.code, kIsolateReloadBarred);
expect(result.message, contains('Unable to hot reload application due to an unrecoverable error'));
verify(globals.flutterUsage.sendEvent('hot', 'reload-barred', parameters: <String, String>{
cdKey(CustomDimensions.hotEventTargetPlatform):
getNameForTargetPlatform(TargetPlatform.android_arm),
cdKey(CustomDimensions.hotEventSdkName): 'Example',
cdKey(CustomDimensions.hotEventEmulator): 'false',
cdKey(CustomDimensions.hotEventFullRestart): 'false',
cdKey(CustomDimensions.nullSafety): 'false',
})).called(1);
expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{
Usage: () => MockUsage(),
}));
testUsingContext('ResidentRunner reports hot reload event with null safety analytics', () => testbed.run(() async { testUsingContext('ResidentRunner reports hot reload event with null safety analytics', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
listViews, listViews,
]); ]);
residentRunner = HotRunner( residentRunner = HotRunner(
...@@ -582,16 +652,8 @@ void main() { ...@@ -582,16 +652,8 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
listViews, listViews,
listViews,
const FakeVmServiceRequest(
method: '_flutter.setAssetBundlePath',
args: <String, Object>{
'viewId': 'a',
'assetDirectory': 'build/flutter_assets',
'isolateId': '1',
}
),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{ jsonResponse: vm_service.VM.parse(<String, Object>{
...@@ -615,7 +677,6 @@ void main() { ...@@ -615,7 +677,6 @@ void main() {
}, },
}, },
), ),
listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -660,7 +721,7 @@ void main() { ...@@ -660,7 +721,7 @@ void main() {
dillOutputPath: anyNamed('dillOutputPath'), dillOutputPath: anyNamed('dillOutputPath'),
packageConfig: anyNamed('packageConfig'), packageConfig: anyNamed('packageConfig'),
)).thenAnswer((Invocation invocation) async { )).thenAnswer((Invocation invocation) async {
return UpdateFSReport(success: true); return UpdateFSReport(success: true, invalidatedSourcesCount: 1);
}); });
final OperationResult result = await residentRunner.restart(fullRestart: false); final OperationResult result = await residentRunner.restart(fullRestart: false);
...@@ -675,16 +736,8 @@ void main() { ...@@ -675,16 +736,8 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
listViews, listViews,
listViews,
const FakeVmServiceRequest(
method: '_flutter.setAssetBundlePath',
args: <String, Object>{
'viewId': 'a',
'assetDirectory': 'build/flutter_assets',
'isolateId': '1',
}
),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{ jsonResponse: vm_service.VM.parse(<String, Object>{
...@@ -756,7 +809,7 @@ void main() { ...@@ -756,7 +809,7 @@ void main() {
dillOutputPath: anyNamed('dillOutputPath'), dillOutputPath: anyNamed('dillOutputPath'),
packageConfig: anyNamed('packageConfig'), packageConfig: anyNamed('packageConfig'),
)).thenAnswer((Invocation invocation) async { )).thenAnswer((Invocation invocation) async {
return UpdateFSReport(success: true); return UpdateFSReport(success: true, invalidatedSourcesCount: 1);
}); });
final OperationResult result = await residentRunner.restart(fullRestart: false); final OperationResult result = await residentRunner.restart(fullRestart: false);
...@@ -772,15 +825,7 @@ void main() { ...@@ -772,15 +825,7 @@ void main() {
listViews, listViews,
listViews, listViews,
listViews, listViews,
listViews, setAssetBundlePath,
const FakeVmServiceRequest(
method: '_flutter.setAssetBundlePath',
args: <String, Object>{
'viewId': 'a',
'assetDirectory': 'build/flutter_assets',
'isolateId': '1',
}
),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: vm_service.VM.parse(<String, Object>{ jsonResponse: vm_service.VM.parse(<String, Object>{
...@@ -804,7 +849,6 @@ void main() { ...@@ -804,7 +849,6 @@ void main() {
}, },
}, },
), ),
listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -856,19 +900,11 @@ void main() { ...@@ -856,19 +900,11 @@ void main() {
), ),
listViews, listViews,
listViews, listViews,
listViews,
const FakeVmServiceRequest(
method: '_flutter.setAssetBundlePath',
args: <String, Object>{
'viewId': 'a',
'assetDirectory': 'build/flutter_assets',
'isolateId': '1',
}
),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: fakeVM.toJson(), jsonResponse: fakeVM.toJson(),
), ),
setAssetBundlePath,
const FakeVmServiceRequest( const FakeVmServiceRequest(
method: 'reloadSources', method: 'reloadSources',
args: <String, Object>{ args: <String, Object>{
...@@ -884,7 +920,6 @@ void main() { ...@@ -884,7 +920,6 @@ void main() {
}, },
}, },
), ),
listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -938,7 +973,11 @@ void main() { ...@@ -938,7 +973,11 @@ void main() {
invalidatedFiles: anyNamed('invalidatedFiles'), invalidatedFiles: anyNamed('invalidatedFiles'),
packageConfig: anyNamed('packageConfig'), packageConfig: anyNamed('packageConfig'),
)).thenAnswer((Invocation invocation) async { )).thenAnswer((Invocation invocation) async {
return UpdateFSReport(success: true, fastReassembleClassName: 'FOO'); return UpdateFSReport(
success: true,
fastReassembleClassName: 'FOO',
invalidatedSourcesCount: 1,
);
}); });
final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync(); final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync();
...@@ -969,6 +1008,7 @@ void main() { ...@@ -969,6 +1008,7 @@ void main() {
listViews, listViews,
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -1038,6 +1078,7 @@ void main() { ...@@ -1038,6 +1078,7 @@ void main() {
listViews, listViews,
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -1113,6 +1154,7 @@ void main() { ...@@ -1113,6 +1154,7 @@ void main() {
listViews, listViews,
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getIsolate', method: 'getIsolate',
args: <String, Object>{ args: <String, Object>{
...@@ -1243,6 +1285,7 @@ void main() { ...@@ -1243,6 +1285,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async { when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
return 'Example'; return 'Example';
...@@ -2112,6 +2155,7 @@ void main() { ...@@ -2112,6 +2155,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2137,6 +2181,7 @@ void main() { ...@@ -2137,6 +2181,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2163,6 +2208,7 @@ void main() { ...@@ -2163,6 +2208,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2197,6 +2243,7 @@ void main() { ...@@ -2197,6 +2243,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2231,6 +2278,7 @@ void main() { ...@@ -2231,6 +2278,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2258,6 +2306,7 @@ void main() { ...@@ -2258,6 +2306,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
setWsAddress(testUri, fakeVmServiceHost.vmService); setWsAddress(testUri, fakeVmServiceHost.vmService);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
...@@ -2322,6 +2371,7 @@ void main() { ...@@ -2322,6 +2371,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
final MockDevicePortForwarder mockPortForwarder = MockDevicePortForwarder(); final MockDevicePortForwarder mockPortForwarder = MockDevicePortForwarder();
when(mockDevice.portForwarder).thenReturn(mockPortForwarder); when(mockDevice.portForwarder).thenReturn(mockPortForwarder);
...@@ -2353,6 +2403,7 @@ void main() { ...@@ -2353,6 +2403,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
listViews, listViews,
setAssetBundlePath,
]); ]);
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner( residentRunner = HotRunner(
......
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