[kernel/flutter] Improve speed of first hot reload

This commit is contained in:
Jens Johansen 2017-12-20 15:05:25 +01:00
parent a96487929b
commit f3dc133878
4 changed files with 10 additions and 3 deletions

View File

@ -50,6 +50,8 @@ class AssetBundle {
}
}
bool wasBuildOnce() => _lastBuildTimestamp != null;
bool needsBuild({String manifestPath: defaultManifestPath}) {
if (_fixed)
return false;

View File

@ -383,6 +383,7 @@ class DevFS {
String mainPath,
String target,
AssetBundle bundle,
bool bundleFirstUpload: false,
bool bundleDirty: false,
Set<String> fileFilter,
ResidentCompiler generator,
@ -445,10 +446,10 @@ class DevFS {
// that isModified does not reset last check timestamp because we
// want to report all modified files to incremental compiler next time
// user does hot reload.
if (content.isModified || (bundleDirty && archivePath != null)) {
if (content.isModified || ((bundleDirty || bundleFirstUpload) && archivePath != null)) {
dirtyEntries[deviceUri] = content;
numBytes += content.size;
if (archivePath != null)
if (archivePath != null && !bundleFirstUpload)
assetPathsToEvict.add(archivePath);
}
});

View File

@ -350,6 +350,7 @@ class FlutterDevice {
String mainPath,
String target,
AssetBundle bundle,
bool bundleFirstUpload: false,
bool bundleDirty: false,
Set<String> fileFilter,
bool fullRestart: false
@ -364,6 +365,7 @@ class FlutterDevice {
mainPath: mainPath,
target: target,
bundle: bundle,
bundleFirstUpload: bundleFirstUpload,
bundleDirty: bundleDirty,
fileFilter: fileFilter,
generator: generator,

View File

@ -260,6 +260,7 @@ class HotRunner extends ResidentRunner {
// Did not update DevFS because of a Dart source error.
return false;
}
final bool isFirstUpload = assetBundle.wasBuildOnce() == false;
final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) {
printTrace('Updating assets');
@ -273,7 +274,8 @@ class HotRunner extends ResidentRunner {
mainPath: mainPath,
target: target,
bundle: assetBundle,
bundleDirty: rebuildBundle,
bundleFirstUpload: isFirstUpload,
bundleDirty: isFirstUpload == false && rebuildBundle,
fileFilter: _dartDependencies,
fullRestart: fullRestart
);