From 6c6d08b9eee993c19a40710e0f9b9e46d9c5cab5 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Fri, 13 Oct 2017 15:18:24 -0700 Subject: [PATCH] Keep incremental compiler state through full restart. (#12535) * Keep incremental compiler state through full restart. * Add todo * Add todo --- packages/flutter_tools/lib/src/devfs.dart | 16 ++++++++++++++++ packages/flutter_tools/lib/src/run_hot.dart | 11 +++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 860a63c32e..5bbba64b9a 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -53,6 +53,13 @@ abstract class DevFSContent { class DevFSFileContent extends DevFSContent { DevFSFileContent(this.file); + static DevFSFileContent clone(DevFSFileContent fsFileContent) { + final DevFSFileContent newFsFileContent = new DevFSFileContent(fsFileContent.file); + newFsFileContent._linkTarget = fsFileContent._linkTarget; + newFsFileContent._fileStat = fsFileContent._fileStat; + return newFsFileContent; + } + final FileSystemEntity file; FileSystemEntity _linkTarget; FileStat _fileStat; @@ -435,6 +442,15 @@ class DevFS { String archivePath; if (deviceUri.path.startsWith(assetBuildDirPrefix)) archivePath = deviceUri.path.substring(assetBuildDirPrefix.length); + // When doing full restart in preview-dart-2 mode, copy content so + // 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. + // TODO(aam): Remove this logic once we switch to using incremental + // compiler for full application compilation when doing full restart. + if (fullRestart && generator != null && content is DevFSFileContent) { + content = DevFSFileContent.clone(content); + } if (content.isModified || (bundleDirty && archivePath != null)) { dirtyEntries[deviceUri] = content; numBytes += content.size; diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 2921fa7032..5cedf09a0e 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -335,14 +335,8 @@ class HotRunner extends ResidentRunner { } final Stopwatch restartTimer = new Stopwatch()..start(); - if (previewDart2) { - for (FlutterDevice device in flutterDevices) { - // Reset generator so that full kernel file is produced for VM to - // restart from. - if (device.generator != null) - device.generator.reset(); - } - } + // TODO(aam): Add generator reset logic once we switch to using incremental + // compiler for full application recompilation on restart. final bool updatedDevFS = await _updateDevFS(fullRestart: true); if (!updatedDevFS) return new OperationResult(1, 'DevFS synchronization failed'); @@ -574,6 +568,7 @@ class HotRunner extends ResidentRunner { printTrace('Skipping reassemble because all isolates are paused.'); return new OperationResult(OperationResult.ok.code, reloadMessage); } + printTrace('Evicting dirty assets'); await _evictDirtyAssets(); printTrace('Reassembling application'); bool reassembleAndScheduleErrors = false;