diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index bc601ae5a5..5946cd3f84 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -67,8 +67,8 @@ abstract class AssetBundle { final ByteData data = await load(key); if (data == null) throw new FlutterError('Unable to load asset: $key'); - if (data.lengthInBytes < 20 * 1024) { - // 20KB takes about 6ms to parse on a Pixel 2 XL. + if (data.lengthInBytes < 10 * 1024) { + // 10KB takes about 3ms to parse on a Pixel 2 XL. // See: https://github.com/dart-lang/sdk/issues/31954 return utf8.decode(data.buffer.asUint8List()); } diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 22b88546b9..c65aa3adab 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -442,7 +442,7 @@ class ResidentCompiler { /// accepted previously so that next call to [recompile] produces complete /// kernel file. void reset() { - _server.stdin.writeln('reset'); + _server?.stdin?.writeln('reset'); } String _mapFilename(String filename) { diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 78b302cc8a..a4905e90f5 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -412,6 +412,7 @@ class DevFS { String dillOutputPath, bool fullRestart = false, String projectRootPath, + String pathToReload, }) async { // Mark all entries as possibly deleted. for (DevFSContent content in _entries.values) { @@ -510,13 +511,12 @@ class DevFS { packagesFilePath : _packagesFilePath); final String compiledBinary = compilerOutput?.outputFilename; if (compiledBinary != null && compiledBinary.isNotEmpty) { - final String entryUri = projectRootPath != null ? - fs.path.relative(mainPath, from: projectRootPath): - mainPath; - final Uri kernelUri = fs.path.toUri(entryUri + '.dill'); - if (!dirtyEntries.containsKey(kernelUri)) { + final Uri entryUri = fs.path.toUri(projectRootPath != null ? + fs.path.relative(pathToReload, from: projectRootPath): + pathToReload); + if (!dirtyEntries.containsKey(entryUri)) { final DevFSFileContent content = new DevFSFileContent(fs.file(compiledBinary)); - dirtyEntries[kernelUri] = content; + dirtyEntries[entryUri] = content; numBytes += content.size; } } diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 516ebdf471..771d83dc60 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -381,6 +381,7 @@ class FlutterDevice { Set fileFilter, bool fullRestart = false, String projectRootPath, + String pathToReload, }) async { final Status devFSStatus = logger.startProgress( 'Syncing files to device ${device.name}...', @@ -400,6 +401,7 @@ class FlutterDevice { fullRestart: fullRestart, dillOutputPath: dillOutputPath, projectRootPath: projectRootPath, + pathToReload: pathToReload ); } on DevFSException { devFSStatus.cancel(); @@ -450,6 +452,10 @@ abstract class ResidentRunner { String get projectRootPath => _projectRootPath; String _mainPath; String get mainPath => _mainPath; + String getReloadPath({bool fullRestart}) => + debuggingOptions.buildInfo.previewDart2 + ? mainPath + (fullRestart? '' : '.incremental') + '.dill' + : mainPath; AssetBundle _assetBundle; AssetBundle get assetBundle => _assetBundle; diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 9ef8235a07..a1ec78bb78 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -180,7 +180,7 @@ class HotRunner extends ResidentRunner { return 3; } final Stopwatch initialUpdateDevFSsTimer = new Stopwatch()..start(); - final bool devfsResult = await _updateDevFS(); + final bool devfsResult = await _updateDevFS(fullRestart: true); _addBenchmarkData('hotReloadInitialDevFSSyncMilliseconds', initialUpdateDevFSsTimer.elapsed.inMilliseconds); if (!devfsResult) @@ -324,6 +324,7 @@ class HotRunner extends ResidentRunner { fileFilter: _dartDependencies, fullRestart: fullRestart, projectRootPath: projectRootPath, + pathToReload: getReloadPath(fullRestart: fullRestart), ); if (!result) return false; @@ -579,7 +580,7 @@ class HotRunner extends ResidentRunner { final Stopwatch vmReloadTimer = new Stopwatch()..start(); try { final String entryPath = fs.path.relative( - debuggingOptions.buildInfo.previewDart2 ? mainPath + '.dill' : mainPath, + getReloadPath(fullRestart: false), from: projectRootPath, ); final Completer> retrieveFirstReloadReport = new Completer>();