Skip to content

[flutter_tools] Include dependency manifests in copyAssets depfile - #196596

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
adityajai119:fix-dependency-asset-depfile
Nov 25, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
adityajai119:fix-dependency-asset-depfile

Conversation

@adityajai119

@adityajai119 adityajai119 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Include existing files from assetBundle.inputFiles in the Depfile returned by copyAssets (flutter_assets.d), and deduplicate input paths while preserving sentinel entries from assetBundle.additionalDependencies.

ManifestAssetBundle.build already records .dart_tool/package_config.json and the pubspec.yaml of each non-dev transitive dependency in assetBundle.inputFiles, but copyAssets previously constructed its Depfile from only the root project's pubspec.yaml, copied asset files, transformer dependencies, and assetBundle.additionalDependencies. When an asset was added to a path dependency's pubspec.yaml between flutter build runs, none of the files listed in flutter_assets.d had changed, so the build system skipped the asset bundle target until flutter clean was run.

Fixes #141626

AI-assisted: drafted with an AI coding agent; dart analyze --fatal-infos, dart format, and the flutter_tools build_system, asset, asset_bundle, assemble, and forbidden_imports test suites were run locally.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

ManifestAssetBundle.build records package_config.json and each runtime
dependency's pubspec.yaml in AssetBundle.inputFiles, but copyAssets did
not include those files in the returned Depfile (flutter_assets.d).
Incremental builds skipped asset bundling after an asset was added to a
path dependency's pubspec.yaml unless flutter clean ran first.

Include existing files from assetBundle.inputFiles in the Depfile
returned by copyAssets and deduplicate input paths while preserving
wildcard sentinel entries from assetBundle.additionalDependencies.

Fixes flutter#141626
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 14, 2026
@adityajai119
adityajai119 marked this pull request as ready for review November 14, 2026 11:40

@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 the asset copying build target to include input files from the asset bundle in its dependency inputs and deduplicates depfile inputs using normalized absolute paths. It also adds a test to verify that the asset bundle rebuilds when a dependency pubspec adds an asset. Feedback suggests using canonicalize instead of normalize for path deduplication to handle case-insensitivity on Windows and macOS, and using canonicalize in the test assertions to ensure platform-independent path comparisons.

Comment on lines +935 to +937
final Set<String> firstInputPaths = firstDepfile.inputs.map((File file) => file.path).toSet();
expect(firstInputPaths, contains('/my_package/pubspec.yaml'));
expect(firstInputPaths, isNot(contains('/dev_package/pubspec.yaml')));

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.

medium

The test asserts on absolute paths using hardcoded POSIX-style strings ('/my_package/pubspec.yaml'). This will fail on Windows because the path separator is \ and the path may contain a drive letter. Use environment.fileSystem.path.canonicalize to ensure the path comparison is platform-independent.

Suggested change
final Set<String> firstInputPaths = firstDepfile.inputs.map((File file) => file.path).toSet();
expect(firstInputPaths, contains('/my_package/pubspec.yaml'));
expect(firstInputPaths, isNot(contains('/dev_package/pubspec.yaml')));
final Set<String> firstInputPaths = firstDepfile.inputs.map((File file) => file.path).toSet();
expect(firstInputPaths, contains(environment.fileSystem.path.canonicalize('my_package/pubspec.yaml')));
expect(firstInputPaths, isNot(contains(environment.fileSystem.path.canonicalize('dev_package/pubspec.yaml'))));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 52ed77f: parameterized the test across both FileSystemStyle.posix and FileSystemStyle.windows using canonicalized path comparisons.

Comment on lines +274 to +278
final depfileInputs = <File>[
for (final File file in <File>[...inputs, ...assetBundle.additionalDependencies])
if (seenInputPaths.add(environment.fileSystem.path.canonicalize(file.path))) file,
];
final depfile = Depfile(depfileInputs, outputs);

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.

Nit: we can avoid allocating an intermediate list here and return the Depfile directly:

  final depfileInputs = <File>[
    for (final File file in inputs.followedBy(assetBundle.additionalDependencies))
      if (seenInputPaths.add(environment.fileSystem.path.canonicalize(file.path))) file,
  ];
  return Depfile(depfileInputs, outputs);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 642d330 to iterate via inputs.followedBy(assetBundle.additionalDependencies) and return Depfile(depfileInputs, outputs) directly.

Comment on lines +894 to +897
for (final style in <FileSystemStyle>[FileSystemStyle.posix, FileSystemStyle.windows]) {
final styleName = style == FileSystemStyle.windows ? 'windows' : 'posix';
testWithoutContext(
'rebuilds asset bundle when a dependency pubspec adds an asset between builds ($styleName)',

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.

Nit: wrap this loop in a group and add a comment linking #141626.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wrapped in group('dependency pubspec changes', ...) with a comment linking #141626 in 642d330.

Comment on lines +912 to +914
testFileSystem
.file(testEnvironment.buildDir.childFile('native_assets.json'))
.createSync(recursive: true);

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.

Is this needed? CopyAssets reads link_hooks_result.json (defaulting to empty when absent), not native_assets.json.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the unused native_assets.json setup in 642d330.

Comment on lines +957 to +960
final Set<String> firstInputPaths = firstDepfile.inputs
.map((File file) => testEnvironment.fileSystem.path.canonicalize(file.path))
.toSet();
expect(firstInputPaths, hasLength(firstDepfile.inputs.length));

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.

DepfileService.parse already calls .toSet() on parsed entries, so expect(firstInputPaths, hasLength(firstDepfile.inputs.length)) passes on POSIX even if duplicate paths were written to flutter_assets.d. Either check raw flutter_assets.d contents or remove this assertion in favor of the direct copyAssets test below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the redundant hasLength assertion in 642d330 in favor of the direct copyAssets deduplication test below.

);
}

class StandaloneCopyAssets extends CopyAssets {

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.

Nit: make this private (_StandaloneCopyAssets) and add a brief comment explaining why dependencies and inputs are overridden.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made _StandaloneCopyAssets private and added a comment explaining the dependencies and inputs overrides in 642d330.

bkonyi
bkonyi previously approved these changes Nov 23, 2026

@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.

LGTM! We'll need one more review before this can land.

@bkonyi
bkonyi requested a review from chingjun November 23, 2026 19:40
chingjun
chingjun previously approved these changes Nov 23, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
@auto-submit

auto-submit Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/196596, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

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

auto-submit Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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

@adityajai119
adityajai119 dismissed stale reviews from chingjun and bkonyi via 8e3eeb9 November 24, 2026 15:48
@adityajai119

Copy link
Copy Markdown
Contributor Author

Merged the latest master (b75c5b30) and added the newly required featureFlags: TestFeatureFlags() at both Environment.test call sites in assets_test.dart (8e3eeb9d). Full packages/flutter_tools dart analyze --fatal-infos . reports no issues, and flutter test assets_test.dart passes 40/40. Tree_analyze's two missing_required_argument errors should be cleared now. Re-requested both reviews -- could you re-approve and re-apply CICD / autosubmit when checks go green? Thanks @bkonyi @chingjun.

@bkonyi bkonyi added the CICD Run CI/CD label Nov 24, 2026
@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into flutter:master with commit 5ed6ff0 Nov 25, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions)

flutter/flutter@b75c5b3...06f1c24

2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375)
2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371)
2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369)
2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364)
2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270)
2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219)
2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714)
2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965)
2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267)
2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363)
2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748)
2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596)
2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071)
2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351)
2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310)
2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266)
2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944)
2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918)
2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815)
2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229)
2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482)
2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300)
2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302)
2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004)
2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334)
2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333)
2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095)
2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355)
2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206)
2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771)
2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245)
2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563)
2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807)
2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316)
2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945)
2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309)
2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313)

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

...
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.

flutter build doesn't include assets added to a path dependency in between builds

3 participants