Unverified Commit 8da5af55 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Send RPC request to switch assets directory on hot reload. (#12872)

* Send RPC request to switch assets directory on hot reload.

This is needed to pick up updated assets that are expected to be picked up on hot reload.

* Assert assets directory is not null.

* Better multiple future wait

* Add type annotation
parent 885e9691
...@@ -141,6 +141,15 @@ class FlutterDevice { ...@@ -141,6 +141,15 @@ class FlutterDevice {
return reports; return reports;
} }
Future<Null> resetAssetDirectory() async {
final Uri deviceAssetsDirectoryUri = devFS.baseUri.resolveUri(
fs.path.toUri(getAssetBuildDirectory()));
assert(deviceAssetsDirectoryUri != null);
await Future.wait(views.map(
(FlutterView view) => view.setAssetDirectory(deviceAssetsDirectoryUri)
));
}
// Lists program elements changed in the most recent reload that have not // Lists program elements changed in the most recent reload that have not
// since executed. // since executed.
Future<List<ProgramElement>> unusedChangesInLastReload() async { Future<List<ProgramElement>> unusedChangesInLastReload() async {
......
...@@ -516,6 +516,8 @@ class HotRunner extends ResidentRunner { ...@@ -516,6 +516,8 @@ class HotRunner extends ResidentRunner {
int countExpectedReports = 0; int countExpectedReports = 0;
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
// List has one report per Flutter view. // List has one report per Flutter view.
await device.resetAssetDirectory();
final List<Future<Map<String, dynamic>>> reports = device.reloadSources( final List<Future<Map<String, dynamic>>> reports = device.reloadSources(
entryPath, entryPath,
pause: pause pause: pause
......
...@@ -1318,6 +1318,15 @@ class FlutterView extends ServiceObject { ...@@ -1318,6 +1318,15 @@ class FlutterView extends ServiceObject {
await subscription.cancel(); await subscription.cancel();
} }
Future<Null> setAssetDirectory(Uri assetsDirectory) async {
assert(assetsDirectory != null);
await owner.vmService.vm.invokeRpc('_flutter.setAssetBundlePath',
params: <String, dynamic>{
'viewId': id,
'assetDirectory': assetsDirectory.toFilePath(windows: false)
});
}
bool get hasIsolate => _uiIsolate != null; bool get hasIsolate => _uiIsolate != null;
Future<Null> flushUIThreadTasks() async { Future<Null> flushUIThreadTasks() async {
......
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