Repository navigation
[tool] Migrate ResidentRunner, HotRunner, and ColdRunner to modular dependency injection - #192831
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Flutter tools codebase by replacing references to global variables with dependency injection across multiple commands, runners, and test files to improve modularity. Feedback on the changes includes resolving a correctness bug in ResidentRunner where multiple distinct MemoryFileSystem instances are instantiated when fileSystem is null, and a recommendation to eliminate redundant instantiations of OperatingSystemUtils in AppDomain.
…utterDevice.create
…ependency injection
5e29d66 to
ea53f23
Compare
…ap in runner.dart
# Conflicts: # packages/flutter_tools/lib/src/resident_runner.dart
# Conflicts: # packages/flutter_tools/test/general.shard/cold_test.dart # packages/flutter_tools/test/general.shard/hot_test.dart
# Conflicts: # packages/flutter_tools/lib/src/commands/run.dart # packages/flutter_tools/lib/src/resident_runner.dart
…gToolContext in runner tests
…rDriverFactory, and Daemon
…n WebRunnerFactory
# Conflicts: # packages/flutter_tools/lib/src/commands/daemon.dart # packages/flutter_tools/lib/src/commands/run.dart # packages/flutter_tools/lib/src/drive/web_driver_service.dart # packages/flutter_tools/lib/src/isolated/resident_web_runner.dart # packages/flutter_tools/lib/src/web/web_runner.dart # packages/flutter_tools/test/commands.shard/hermetic/run_test.dart # packages/flutter_tools/test/general.shard/drive/web_driver_service_test.dart
# Conflicts: # packages/flutter_tools/lib/src/commands/daemon.dart # packages/flutter_tools/lib/src/commands/run.dart # packages/flutter_tools/lib/src/commands/widget_preview.dart # packages/flutter_tools/lib/src/drive/web_driver_service.dart # packages/flutter_tools/lib/src/isolated/resident_web_runner.dart # packages/flutter_tools/lib/src/web/web_runner.dart # packages/flutter_tools/test/commands.shard/hermetic/run_test.dart # packages/flutter_tools/test/commands.shard/permeable/widget_preview/widget_preview_test.dart # packages/flutter_tools/test/general.shard/drive/web_driver_service_test.dart
# Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
|
autosubmit label was removed for flutter/flutter/192831, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/192831, because Pull request flutter/flutter/192831 is not in a mergeable state. |
# Conflicts: # packages/flutter_tools/lib/src/resident_runner.dart
…eview and trigger hot restart (flutter#193968) Reverts: [[flutter_tools] Intercept prohibited hot reloads in widget preview and trigger hot restart](flutter#193447) Initiated by: @bkonyi Reason for reverting: conflicting changes with flutter#192831 are causing failures due to concurrent merge Original PR Author: @bkonyi Reviewed By: @srawlins The original PR description is provided below: When hot reload fails due to unsupported changes (such as class hierarchy modifications, global initializer changes, or file additions/deletions) in `flutter widget-preview`, automatically fall back to a hot restart instead of leaving the previewer in a failed reload state. ### Changes - **`ResidentWebRunner`**: Attach `updateFSReport` to the failed `OperationResult` when `_updateDevFS` fails so callers can inspect `UpdateFSReport.hotReloadRejected`. - **`WidgetPreviewStartCommand`**: Introduce `handleReload()` (invoked inside `_triggerReload` for `.hotReload` requests so the fallback remains serialized with other reload and restart requests, and add a `@visibleForTesting` `widgetPreviewApp` setter), which checks if `restart()` returned an `OperationResult` with `UpdateFSReport(hotReloadRejected: true)`. When rejected, log a status message (`kHotReloadRejectedMessage`) and invoke `restart(fullRestart: true)`. Fixes flutter#192697 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Summary
Part 22b of the modular dependency injection migration.
ResidentRunner,HotRunner,ColdRunner, andResidentWebRunnerto modular constructor dependency injection.BuildSystem,BuildTargets, andXcodethroughDaemonCommand,Daemon,AppDomain,AttachCommand,RunCommand.createRunner,WebDriverService.start, andWidgetPreviewStartCommand.toolContextnon-nullable withconst DelegatingToolContext()default increateHotRunner,createColdRunner, andsetUpResidentRunnertest helpers, and migrates unit tests inattach_test.dart,daemon_test.dart,cold_test.dart,hot_test.dart,resident_runner_test.dart, andresident_web_runner_test.dart.Fork diff: bkonyi/flutter@master...di/22b-resident-runner
Part of #188471