Skip to content

[tool] Let --local-engine reach the build system again - #192361

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
robert-ancell:local-engine-artifacts-fix
Sep 8, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
robert-ancell:local-engine-artifacts-fix

Conversation

@robert-ancell

Copy link
Copy Markdown
Contributor

Desktop builds with --local-engine quietly used the cached engine instead of the one just built, and often failed outright with "Can't load Kernel binary: Invalid SDK hash", because cached engine artifacts stop being updated once --local-engine is used and eventually no longer match the Dart SDK.

Commands are created with the artifacts to build against when the tool starts up, which is before the command line has been parsed, so they always used the cached ones. --local-engine and --local-web-sdk were applied afterwards, and only to the legacy zone that commands used to read artifacts from. flutter assemble stopped reading from that zone in #190773, taking the build system with it.

Use artifacts that can be changed after they are created instead, and update them as soon as the runner has parsed the command line, which happens before any command runs. Everything then builds against the right engine.

Desktop builds with --local-engine quietly used the cached engine instead of
the one just built, and often failed outright with "Can't load Kernel binary:
Invalid SDK hash", because cached engine artifacts stop being updated once
--local-engine is used and eventually no longer match the Dart SDK.

Commands are created with the artifacts to build against when the tool starts
up, which is before the command line has been parsed, so they always used the
cached ones. --local-engine and --local-web-sdk were applied afterwards, and
only to the legacy zone that commands used to read artifacts from. flutter
assemble stopped reading from that zone in flutter#190773, taking the build system
with it.

Use artifacts that can be changed after they are created instead, and update
them as soon as the runner has parsed the command line, which happens before
any command runs. Everything then builds against the right engine.
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 7, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the DeferredArtifacts class to allow resolving artifact dependencies after tool startup, specifically when a local engine is specified. It updates dependency injection in tool_dependencies.dart and command execution in flutter_command_runner.dart, and adds corresponding unit tests. Review feedback suggests adding documentation warnings against eager caching, adding assertions to prevent self-resolution and nested wrapping, and using an explicit bool type instead of var for _isResolved to align with the Flutter style guide.

Comment thread packages/flutter_tools/lib/src/artifacts.dart
Comment thread packages/flutter_tools/lib/src/artifacts.dart
Comment thread packages/flutter_tools/lib/src/artifacts.dart
Comment thread packages/flutter_tools/lib/src/artifacts.dart

@mattkae mattkae left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK by me, but I suggest getting someone more privy to the artifacts system to review it 👍

@robert-ancell
robert-ancell requested a review from bkonyi September 7, 2026 23:56

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit

auto-submit Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192361, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 8, 2026
Merged via the queue into flutter:master with commit 20b9fec Sep 8, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 8, 2026
flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@cbracken

cbracken commented Sep 9, 2026

Copy link
Copy Markdown
Member

Thanks for the fix!

@bkonyi as a followup I think it would be really good if we could understand how something could break every engine/embedder developers' workflow without the pre/post submits catching it.

Without having looked into the code, it seems like we must be missing some pretty important test coverage here.

victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12791)

flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12791)

flutter/flutter@63170e9...b444e78

2026-09-08 [email protected] Clean up lint errors in workflows (flutter/flutter#191987)
2026-09-08 [email protected] Remove no-shuffle tag from dropdown_test.dart (flutter/flutter#186398)
2026-09-08 [email protected] Remove no-shuffle from scrollbar test (flutter/flutter#186656)
2026-09-08 [email protected] [tool] Let --local-engine reach the build system again (flutter/flutter#192361)
2026-09-08 [email protected] [flutter_tools] Safely remove web loading indicator on dart-app-ready (flutter/flutter#192233)
2026-09-08 [email protected] [Linux] Don't clear the OpenGL context when a frame has been drawn (flutter/flutter#192137)
2026-09-08 [email protected] ci: update dartdoc from 9.0.6 to 9.0.9 (flutter/flutter#192405)
2026-09-07 [email protected] Add itemExtentBuilder support to ListView.separated (flutter/flutter#191157)
2026-09-07 [email protected] Roll Skia from e1437642d259 to b3fa80a0e168 (5 revisions) (flutter/flutter#192362)
2026-09-07 [email protected] Roll Skia from 2df865d9d369 to e1437642d259 (1 revision) (flutter/flutter#192360)
2026-09-07 [email protected] Roll Skia from c7aa5512d148 to 2df865d9d369 (2 revisions) (flutter/flutter#192357)
2026-09-06 [email protected] Roll Skia from db200e27a634 to c7aa5512d148 (2 revisions) (flutter/flutter#192351)
2026-09-06 [email protected] Roll Fuchsia Linux SDK from _IgixhH4vEgdz9Oqn... to p8hHkUi8uWT9R3N4z... (flutter/flutter#192349)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
chingjun pushed a commit to chingjun/flutter that referenced this pull request Oct 7, 2026
…mmands and DI (flutter#192510)

## Description

Adds tests verifying that local engine options specified via CLI flags
or artifacts are properly propagated across `flutter_tools` commands and
dependency injection bootstrapping, addressing [flutter#192361
(comment)](flutter#192361 (comment)).
Also refactors `Artifacts.getLocalEngine` to make `cache`, `fileSystem`,
`operatingSystemUtils`, `platform`, and `processManager` required named
parameters, eliminating ambient `globals.*` fallbacks.

## Related Issues
- Follow-up to [flutter#192361](flutter#192361)

## Tests
- Hermetic unit tests in
`packages/flutter_tools/test/commands.shard/hermetic/`
(`assemble_test.dart`, `build_ios_test.dart`, `build_linux_test.dart`,
`build_macos_test.dart`, `build_web_test.dart`,
`build_windows_test.dart`)
- Unit tests in `packages/flutter_tools/test/general.shard/`
(`bundle_builder_test.dart`, `context/dependency_injection_test.dart`,
`runner/flutter_command_runner_test.dart`)
- Integration test in
`packages/flutter_tools/test/integration.shard/build_linux_config_only_test.dart`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants