mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] check asset files while the tool waits for the frontend_server compile (#67826)
On every hot reload, the flutter tool must file stat each asset in the bundle. With a large number of assets or a slow file system, this can take 20 - 30 ms. Do this operation while the flutter tool is waiting for a response from the frontend_server. No tests updated since this is only a timing update. Any difference in behavior will be shown on benchmarks
This commit is contained in:
parent
354e2a57b1
commit
408cd71d82
@ -499,14 +499,31 @@ class DevFS {
|
|||||||
|
|
||||||
// Update modified files
|
// Update modified files
|
||||||
final Map<Uri, DevFSContent> dirtyEntries = <Uri, DevFSContent>{};
|
final Map<Uri, DevFSContent> dirtyEntries = <Uri, DevFSContent>{};
|
||||||
|
|
||||||
int syncedBytes = 0;
|
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<CompilerOutput> pendingCompilerOutput = generator.recompile(
|
||||||
|
mainUri,
|
||||||
|
invalidatedFiles,
|
||||||
|
outputPath: dillOutputPath ?? getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation),
|
||||||
|
packageConfig: packageConfig,
|
||||||
|
);
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
final String assetBuildDirPrefix = _asUriPath(getAssetBuildDirectory());
|
|
||||||
// The tool writes the assets into the AssetBundle working dir so that they
|
// The tool writes the assets into the AssetBundle working dir so that they
|
||||||
// are in the same location in DevFS and the iOS simulator.
|
// are in the same location in DevFS and the iOS simulator.
|
||||||
|
final String assetBuildDirPrefix = _asUriPath(getAssetBuildDirectory());
|
||||||
final String assetDirectory = getAssetBuildDirectory();
|
final String assetDirectory = getAssetBuildDirectory();
|
||||||
bundle.entries.forEach((String archivePath, DevFSContent content) {
|
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) {
|
if (!content.isModified || bundleFirstUpload) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -521,19 +538,7 @@ class DevFS {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (fullRestart) {
|
final CompilerOutput compilerOutput = await pendingCompilerOutput;
|
||||||
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,
|
|
||||||
);
|
|
||||||
if (compilerOutput == null || compilerOutput.errorCount > 0) {
|
if (compilerOutput == null || compilerOutput.errorCount > 0) {
|
||||||
return UpdateFSReport(success: false);
|
return UpdateFSReport(success: false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user