Skip to content

Fix XcodeProjectInterpreter dependency cycle in flutter_tools - #195694

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
kevmoo:fix-cache-cycle
Oct 30, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
kevmoo:fix-cache-cycle

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Defer xcode and xcodeProjectInterpreter evaluation in globals.projectFactory by passing xcodeBuilder: () => xcode and xcodeProjectInterpreterBuilder: () => xcodeProjectInterpreter instead of eagerly evaluating the context.get getters.

Previously, accessing globals.projectFactory (e.g., via Cache during Analytics initialization) eagerly evaluated globals.xcode and globals.xcodeProjectInterpreter, triggering an AppContext dependency cycle (Analytics -> Cache -> Xcode -> XcodeProjectInterpreter).

Includes a regression test in packages/flutter_tools/test/general.shard/globals_test.dart.

Part of #47161
Related to #188471

Pre-launch Checklist

This fixes an issue where accessing `globals.projectFactory` would immediately evaluate `globals.xcode` and `globals.xcodeProjectInterpreter`, creating a circular dependency cycle when Analytics initializes the Cache.

Fixes flutter#47161

Fixes flutter#188471
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 30, 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 updates globals.dart to lazily evaluate Xcode and XcodeProjectInterpreter by using builder functions, and introduces a new test file to verify this lazy evaluation. The review feedback suggests removing a redundant null assertion on a non-nullable object and making the fake test classes private to follow Dart best practices.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 30, 2026
@harryterkelsen
harryterkelsen self-requested a review October 30, 2026 18:27
@kevmoo
kevmoo requested a review from harryterkelsen October 30, 2026 20:35
harryterkelsen
harryterkelsen previously approved these changes Oct 30, 2026
# Conflicts:
#	packages/flutter_tools/lib/src/globals.dart
@kevmoo
kevmoo requested a review from harryterkelsen October 30, 2026 22:02
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 30, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 30, 2026
@auto-submit

auto-submit Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

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

@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 30, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 30, 2026
Merged via the queue into flutter:master with commit f696546 Oct 30, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 30, 2026
@kevmoo
kevmoo deleted the fix-cache-cycle branch October 31, 2026 00:14
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 31, 2026
flutter/flutter@5e805bf...ee8b482

2026-10-31 [email protected] Roll Skia from 9bab765df357 to 607de4b035dc (1 revision) (flutter/flutter#195728)
2026-10-31 [email protected] Roll Skia from 284054bec98a to 9bab765df357 (2 revisions) (flutter/flutter#195726)
2026-10-31 [email protected] Roll Skia from 3a3f56f7ddd4 to 284054bec98a (1 revision) (flutter/flutter#195724)
2026-10-31 [email protected] Roll Skia from 466994d27b1e to 3a3f56f7ddd4 (1 revision) (flutter/flutter#195719)
2026-10-30 [email protected] Fix XcodeProjectInterpreter dependency cycle in flutter_tools (flutter/flutter#195694)
2026-10-30 [email protected] Document that Positioned also works inside an Overlay (flutter/flutter#190607)
2026-10-30 [email protected] Roll Skia from ce0b85b46db6 to 466994d27b1e (3 revisions) (flutter/flutter#195711)
2026-10-30 [email protected] Adds Vulkan sync validation test run (flutter/flutter#195596)
2026-10-30 [email protected] [Android] Let the raster thread use every core of a chip without little cores (flutter/flutter#195071)
2026-10-30 [email protected] Roll Skia from 121d04c01e2d to ce0b85b46db6 (6 revisions) (flutter/flutter#195699)
2026-10-30 [email protected] [web] Anchor platform view slots to top-left to fix RTL document layout (flutter/flutter#194601)
2026-10-30 [email protected] Update golden file testing docs (flutter/flutter#195449)
2026-10-30 [email protected] [tool] Migrate Cache.flutterRoot static state to instance configuration (flutter/flutter#190795)
2026-10-30 [email protected] Apply view metrics overrides below the framework (flutter/flutter#194311)
2026-10-30 [email protected] Roll Skia from c0c46ee9f938 to 121d04c01e2d (9 revisions) (flutter/flutter#195687)
2026-10-30 [email protected] Use uniforms in the Porter Duff blend shader instead of specialization constants (flutter/flutter#195458)
2026-10-30 [email protected] [flutter_tools] Inject dependencies into iOS, macOS, and Windows application packages (flutter/flutter#194047)

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
gmackall pushed a commit to gmackall/flutter that referenced this pull request Nov 3, 2026
…r#195694)

Defer `xcode` and `xcodeProjectInterpreter` evaluation in
`globals.projectFactory` by passing `xcodeBuilder: () => xcode` and
`xcodeProjectInterpreterBuilder: () => xcodeProjectInterpreter` instead
of eagerly evaluating the `context.get` getters.

Previously, accessing `globals.projectFactory` (e.g., via `Cache` during
`Analytics` initialization) eagerly evaluated `globals.xcode` and
`globals.xcodeProjectInterpreter`, triggering an `AppContext` dependency
cycle (`Analytics -> Cache -> Xcode -> XcodeProjectInterpreter`).

Includes a regression test in
`packages/flutter_tools/test/general.shard/globals_test.dart`.

Part of flutter#47161
Related to flutter#188471

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
- [ ] I updated/added relevant in-code documentation (doc comments with
`///`).
- [ ] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[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/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
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.

2 participants