Preserve original kernel file for isolate spawn requests. (#18127)
* Preserve original kernel file for isolate spawn requests. This change gives incremental kernel files ".incremental.dill" extension thereby preserving original kernel file. Bug: https://github.com/flutter/flutter/issues/16084 Bug: https://github.com/flutter/flutter/issues/17012 Bug: https://github.com/flutter/flutter/issues/17983 * Factor out naming logic into separate function * Fix string vs uri
This commit is contained in:
committed by
GitHub
parent
1363bd1795
commit
b075229d85
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +381,7 @@ class FlutterDevice {
|
||||
Set<String> 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;
|
||||
|
||||
|
||||
@@ -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<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>();
|
||||
|
||||
Reference in New Issue
Block a user