Unverified Commit 60869e0a authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Improve time to development by initializing frontend_server concurrently with...

Improve time to development by initializing frontend_server concurrently with platform build (#45236)
parent 0a66d8a7
......@@ -468,7 +468,6 @@ abstract class ResidentCompiler {
List<String> dartDefines,
}) = DefaultResidentCompiler;
/// If invoked for the first time, it compiles Dart script identified by
/// [mainPath], [invalidatedFiles] list is ignored.
/// On successive runs [invalidatedFiles] indicates which files need to be
......
......@@ -487,6 +487,9 @@ 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.
printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
final CompilerOutput compilerOutput = await generator.recompile(
mainPath,
......
......@@ -18,6 +18,7 @@ import 'base/platform.dart';
import 'base/terminal.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'bundle.dart';
import 'compile.dart';
import 'convert.dart';
import 'devfs.dart';
......@@ -262,14 +263,31 @@ class HotRunner extends ResidentRunner {
firstBuildTime = DateTime.now();
final List<Future<bool>> startupTasks = <Future<bool>>[];
for (FlutterDevice device in flutterDevices) {
final int result = await device.runHot(
// Here we initialize the frontend_server conccurently with the gradle
// build, reducing initialization time. This is safe because the first
// invocation of the frontend server produces a full dill file that
// the subsequent invocation in devfs will not overwrite.
if (device.generator != null) {
startupTasks.add(
device.generator.recompile(
mainPath,
<Uri>[],
outputPath: dillOutputPath ??
getDefaultApplicationKernelPath(trackWidgetCreation: device.trackWidgetCreation),
packagesFilePath : packagesFilePath,
).then((CompilerOutput output) => output?.errorCount == 0)
);
}
startupTasks.add(device.runHot(
hotRunner: this,
route: route,
);
if (result != 0) {
return result;
}
).then((int result) => result == 0));
}
final List<bool> results = await Future.wait(startupTasks);
if (!results.every((bool passed) => passed)) {
return 1;
}
return attach(
......
......@@ -108,13 +108,18 @@ void main() {
});
test('hot reload doesn\'t reassemble if paused', () async {
await _flutter.run(withDebugger: true);
final Future<void> setup = _flutter.run(withDebugger: true);
final Completer<void> sawTick1 = Completer<void>();
final Completer<void> sawTick2 = Completer<void>();
final Completer<void> sawTick3 = Completer<void>();
final Completer<void> sawDebuggerPausedMessage1 = Completer<void>();
final Completer<void> sawDebuggerPausedMessage2 = Completer<void>();
final StreamSubscription<String> subscription = _flutter.stdout.listen(
(String line) {
if (line.contains('((((TICK 1))))')) {
expect(sawTick1.isCompleted, isFalse);
sawTick1.complete();
}
if (line.contains('((((TICK 2))))')) {
expect(sawTick2.isCompleted, isFalse);
sawTick2.complete();
......@@ -129,6 +134,8 @@ void main() {
}
},
);
await setup;
await sawTick1.future;
await _flutter.addBreakpoint(
_project.buildBreakpointUri,
_project.buildBreakpointLine,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment