Repository navigation
[flutter_tools] Include dependency manifests in copyAssets depfile - #196596
Conversation
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
There was a problem hiding this comment.
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.
| 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'))); |
There was a problem hiding this comment.
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.
| 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')))); |
There was a problem hiding this comment.
Updated in 52ed77f: parameterized the test across both FileSystemStyle.posix and FileSystemStyle.windows using canonicalized path comparisons.
| 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); |
There was a problem hiding this comment.
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);There was a problem hiding this comment.
Updated in 642d330 to iterate via inputs.followedBy(assetBundle.additionalDependencies) and return Depfile(depfileInputs, outputs) directly.
| 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)', |
There was a problem hiding this comment.
Nit: wrap this loop in a group and add a comment linking #141626.
| testFileSystem | ||
| .file(testEnvironment.buildDir.childFile('native_assets.json')) | ||
| .createSync(recursive: true); |
There was a problem hiding this comment.
Is this needed? CopyAssets reads link_hooks_result.json (defaulting to empty when absent), not native_assets.json.
There was a problem hiding this comment.
Removed the unused native_assets.json setup in 642d330.
| final Set<String> firstInputPaths = firstDepfile.inputs | ||
| .map((File file) => testEnvironment.fileSystem.path.canonicalize(file.path)) | ||
| .toSet(); | ||
| expect(firstInputPaths, hasLength(firstDepfile.inputs.length)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Removed the redundant hasLength assertion in 642d330 in favor of the direct copyAssets deduplication test below.
| ); | ||
| } | ||
|
|
||
| class StandaloneCopyAssets extends CopyAssets { |
There was a problem hiding this comment.
Nit: make this private (_StandaloneCopyAssets) and add a brief comment explaining why dependencies and inputs are overridden.
There was a problem hiding this comment.
Made _StandaloneCopyAssets private and added a comment explaining the dependencies and inputs overrides in 642d330.
bkonyi
left a comment
There was a problem hiding this comment.
LGTM! We'll need one more review before this can land.
|
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. |
|
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. |
|
Merged the latest |
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 ...
Include existing files from
assetBundle.inputFilesin theDepfilereturned bycopyAssets(flutter_assets.d), and deduplicate input paths while preserving sentinel entries fromassetBundle.additionalDependencies.ManifestAssetBundle.buildalready records.dart_tool/package_config.jsonand thepubspec.yamlof each non-dev transitive dependency inassetBundle.inputFiles, butcopyAssetspreviously constructed itsDepfilefrom only the root project'spubspec.yaml, copied asset files, transformer dependencies, andassetBundle.additionalDependencies. When an asset was added to a path dependency'spubspec.yamlbetweenflutter buildruns, none of the files listed influtter_assets.dhad changed, so the build system skipped the asset bundle target untilflutter cleanwas run.Fixes #141626
AI-assisted: drafted with an AI coding agent;
dart analyze --fatal-infos,dart format, and theflutter_toolsbuild_system,asset,asset_bundle,assemble, andforbidden_importstest 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-assistbot 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.