Skip to content

Commit 889a15e

Browse files
authored
[flutter_tools] add needsFullRestart flag on hot runner (#104562)
1 parent 3f1f0a8 commit 889a15e

File tree

7 files changed

+13
-2
lines changed

7 files changed

+13
-2
lines changed

packages/flutter_tools/lib/src/isolated/resident_web_runner.dart

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ class ResidentWebRunner extends ResidentRunner {
518518
Completer<void> appStartedCompleter,
519519
bool allowExistingDdsInstance = false,
520520
bool enableDevTools = false, // ignored, we don't yet support devtools for web
521+
bool needsFullRestart = true,
521522
}) async {
522523
if (_chromiumLauncher != null) {
523524
final Chromium chrome = await _chromiumLauncher.connectedInstance;

packages/flutter_tools/lib/src/resident_runner.dart

+5
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,16 @@ abstract class ResidentRunner extends ResidentHandlers {
11781178
String route,
11791179
});
11801180

1181+
/// Connect to a flutter application.
1182+
///
1183+
/// [needsFullRestart] defaults to `true`, and controls if the frontend server should
1184+
/// 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.
11811185
Future<int> attach({
11821186
Completer<DebugConnectionInfo> connectionInfoCompleter,
11831187
Completer<void> appStartedCompleter,
11841188
bool allowExistingDdsInstance = false,
11851189
bool enableDevTools = false,
1190+
bool needsFullRestart = true,
11861191
});
11871192

11881193
@override

packages/flutter_tools/lib/src/run_cold.dart

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class ColdRunner extends ResidentRunner {
152152
Completer<void> appStartedCompleter,
153153
bool allowExistingDdsInstance = false,
154154
bool enableDevTools = false,
155+
bool needsFullRestart = true,
155156
}) async {
156157
_didAttach = true;
157158
try {

packages/flutter_tools/lib/src/run_hot.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class HotRunner extends ResidentRunner {
228228
Completer<void> appStartedCompleter,
229229
bool allowExistingDdsInstance = false,
230230
bool enableDevTools = false,
231+
bool needsFullRestart = true,
231232
}) async {
232233
_didAttach = true;
233234
try {
@@ -276,7 +277,7 @@ class HotRunner extends ResidentRunner {
276277
}
277278

278279
final Stopwatch initialUpdateDevFSsTimer = Stopwatch()..start();
279-
final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: true);
280+
final UpdateFSReport devfsResult = await _updateDevFS(fullRestart: needsFullRestart);
280281
_addBenchmarkData(
281282
'hotReloadInitialDevFSSyncMilliseconds',
282283
initialUpdateDevFSsTimer.elapsed.inMilliseconds,
@@ -436,6 +437,7 @@ class HotRunner extends ResidentRunner {
436437
connectionInfoCompleter: connectionInfoCompleter,
437438
appStartedCompleter: appStartedCompleter,
438439
enableDevTools: enableDevTools,
440+
needsFullRestart: false,
439441
);
440442
}
441443

packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart

+1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class FakeHotRunner extends Fake implements HotRunner {
477477
Completer<void> appStartedCompleter,
478478
bool allowExistingDdsInstance = false,
479479
bool enableDevTools = false,
480+
bool needsFullRestart = true,
480481
}) {
481482
return onAttach(connectionInfoCompleter, appStartedCompleter, allowExistingDdsInstance, enableDevTools);
482483
}

packages/flutter_tools/test/general.shard/hot_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void main() {
514514
final int exitCode = await HotRunner(devices,
515515
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
516516
target: 'main.dart',
517-
).attach();
517+
).attach(needsFullRestart: false);
518518
expect(exitCode, 2);
519519
}, overrides: <Type, Generator>{
520520
HotRunnerConfig: () => TestHotRunnerConfig(),

packages/flutter_tools/test/general.shard/terminal_handler_test.dart

+1
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ class TestRunner extends Fake implements ResidentRunner {
14671467
Completer<void> appStartedCompleter,
14681468
bool allowExistingDdsInstance = false,
14691469
bool enableDevTools = false,
1470+
bool needsFullRestart = true,
14701471
}) async => null;
14711472
}
14721473

0 commit comments

Comments
 (0)