diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 32093eb73c4..fd7f6048b3d 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -499,14 +499,31 @@ class DevFS { // Update modified files final Map dirtyEntries = {}; - int syncedBytes = 0; + if (fullRestart) { + generator.reset(); + } + // On a full restart, or on an initial compile for the attach based workflow, + // this will produce a full dill. Subsequent invocations will produce incremental + // dill files that depend on the invalidated files. + _logger.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files'); + + // Await the compiler response after checking if the bundle is updated. This allows the file + // stating to be done while waiting for the frontend_server response. + final Future pendingCompilerOutput = generator.recompile( + mainUri, + invalidatedFiles, + outputPath: dillOutputPath ?? getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation), + packageConfig: packageConfig, + ); if (bundle != null) { - final String assetBuildDirPrefix = _asUriPath(getAssetBuildDirectory()); // The tool writes the assets into the AssetBundle working dir so that they // are in the same location in DevFS and the iOS simulator. + final String assetBuildDirPrefix = _asUriPath(getAssetBuildDirectory()); final String assetDirectory = getAssetBuildDirectory(); bundle.entries.forEach((String archivePath, DevFSContent content) { + // If the content is backed by a real file, isModified will file stat and return true if + // it was modified since the last time this was called. if (!content.isModified || bundleFirstUpload) { return; } @@ -521,19 +538,7 @@ class DevFS { } }); } - if (fullRestart) { - generator.reset(); - } - // On a full restart, or on an initial compile for the attach based workflow, - // this will produce a full dill. Subsequent invocations will produce incremental - // dill files that depend on the invalidated files. - _logger.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files'); - final CompilerOutput compilerOutput = await generator.recompile( - mainUri, - invalidatedFiles, - outputPath: dillOutputPath ?? getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation), - packageConfig: packageConfig, - ); + final CompilerOutput compilerOutput = await pendingCompilerOutput; if (compilerOutput == null || compilerOutput.errorCount > 0) { return UpdateFSReport(success: false); }