From 889a15eb9df6961b9a4dc3bf751ff67cb54a2065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20S=20Guerrero?= Date: Fri, 3 Jun 2022 10:18:16 -0700 Subject: [PATCH] [flutter_tools] add needsFullRestart flag on hot runner (#104562) --- .../flutter_tools/lib/src/isolated/resident_web_runner.dart | 1 + packages/flutter_tools/lib/src/resident_runner.dart | 5 +++++ packages/flutter_tools/lib/src/run_cold.dart | 1 + packages/flutter_tools/lib/src/run_hot.dart | 4 +++- .../test/commands.shard/hermetic/attach_test.dart | 1 + packages/flutter_tools/test/general.shard/hot_test.dart | 2 +- .../test/general.shard/terminal_handler_test.dart | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart index 7ec9748f6b5a1..9a5e3c90f8fde 100644 --- a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart @@ -518,6 +518,7 @@ class ResidentWebRunner extends ResidentRunner { Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, // ignored, we don't yet support devtools for web + bool needsFullRestart = true, }) async { if (_chromiumLauncher != null) { final Chromium chrome = await _chromiumLauncher.connectedInstance; diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 0f1c3c698b276..1774909763e6c 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -1178,11 +1178,16 @@ abstract class ResidentRunner extends ResidentHandlers { String route, }); + /// Connect to a flutter application. + /// + /// [needsFullRestart] defaults to `true`, and controls if the frontend server should + /// compile a full dill. This should be set to `false` if this is called in [ResidentRunner.run], since that method already perfoms an initial compilation. Future attach({ Completer connectionInfoCompleter, Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, + bool needsFullRestart = true, }); @override diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index 153e3b34849c2..ebbcb57ac7e66 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart @@ -152,6 +152,7 @@ class ColdRunner extends ResidentRunner { Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, + bool needsFullRestart = true, }) async { _didAttach = true; try { diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 5a0c0e856262d..e2dfe5147cbbf 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -228,6 +228,7 @@ class HotRunner extends ResidentRunner { Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, + bool needsFullRestart = true, }) async { _didAttach = true; try { @@ -276,7 +277,7 @@ class HotRunner extends ResidentRunner { } final Stopwatch initialUpdateDevFSsTimer = Stopwatch()..start(); - final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: true); + final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: needsFullRestart); _addBenchmarkData( 'hotReloadInitialDevFSSyncMilliseconds', initialUpdateDevFSsTimer.elapsed.inMilliseconds, @@ -436,6 +437,7 @@ class HotRunner extends ResidentRunner { connectionInfoCompleter: connectionInfoCompleter, appStartedCompleter: appStartedCompleter, enableDevTools: enableDevTools, + needsFullRestart: false, ); } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index 0674a27728714..2575d7f527906 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -477,6 +477,7 @@ class FakeHotRunner extends Fake implements HotRunner { Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, + bool needsFullRestart = true, }) { return onAttach(connectionInfoCompleter, appStartedCompleter, allowExistingDdsInstance, enableDevTools); } diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart index f51cabfbba176..f68fbe0a34317 100644 --- a/packages/flutter_tools/test/general.shard/hot_test.dart +++ b/packages/flutter_tools/test/general.shard/hot_test.dart @@ -514,7 +514,7 @@ void main() { final int exitCode = await HotRunner(devices, debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), target: 'main.dart', - ).attach(); + ).attach(needsFullRestart: false); expect(exitCode, 2); }, overrides: { HotRunnerConfig: () => TestHotRunnerConfig(), diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart index fbf366d1708fa..e9af1ef59c886 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -1467,6 +1467,7 @@ class TestRunner extends Fake implements ResidentRunner { Completer appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, + bool needsFullRestart = true, }) async => null; }