Skip to content

Commit

Permalink
[flutter_tools] add needsFullRestart flag on hot runner (#104562)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasguerrero authored Jun 3, 2022
1 parent 3f1f0a8 commit 889a15e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class ResidentWebRunner extends ResidentRunner {
Completer<void> 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;
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter_tools/lib/src/resident_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> attach({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
});

@override
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_tools/lib/src/run_cold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class ColdRunner extends ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) async {
_didAttach = true;
try {
Expand Down
4 changes: 3 additions & 1 deletion packages/flutter_tools/lib/src/run_hot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class HotRunner extends ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) async {
_didAttach = true;
try {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -436,6 +437,7 @@ class HotRunner extends ResidentRunner {
connectionInfoCompleter: connectionInfoCompleter,
appStartedCompleter: appStartedCompleter,
enableDevTools: enableDevTools,
needsFullRestart: false,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ class FakeHotRunner extends Fake implements HotRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) {
return onAttach(connectionInfoCompleter, appStartedCompleter, allowExistingDdsInstance, enableDevTools);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tools/test/general.shard/hot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Type, Generator>{
HotRunnerConfig: () => TestHotRunnerConfig(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ class TestRunner extends Fake implements ResidentRunner {
Completer<void> appStartedCompleter,
bool allowExistingDdsInstance = false,
bool enableDevTools = false,
bool needsFullRestart = true,
}) async => null;
}

Expand Down

0 comments on commit 889a15e

Please sign in to comment.