[web] Support runtime content-hashed asset resolution in web_ui and un-hide --web-content-hash
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.6k
- PR merge metrics
- PR metrics pending
Description
Summary
Part of umbrella issue #149031.
With physical static assets now content-hashed on disk during flutter build web --web-content-hash (#191915 / #191919), calls to load assets by raw unhashed key (rootBundle.load, rootBundle.loadString, vector_graphics AssetBytesLoader, video_player_web, and DOM media plugins) encounter 404 errors on fresh browser caches because runtime code requests unhashed logical paths directly over the 'flutter/assets' platform channel or via ui_web.assetManager.getAssetUrl(key).
Additionally, serving asset manifests (AssetManifest.bin.json, FontManifest.json) with fixed unhashed filenames prevents web hosting configurations from caching assets/** with Cache-Control: immutable without complex no-cache carve-outs for manifests, shaders, and notices.
Scope & Requirements
- Web Engine Runtime Asset Resolution (
ui_web.AssetManager):- In
engine/src/flutter/lib/web_ui/, teachui_web.AssetManagerto resolve raw logical keys (assets/data/config.json) to content-hashed paths synchronously viaAssetManager.getAssetUrl(asset). - In
initialization.dart, ingest the key-to-hash mapping duringinitializeEngineServices()(via_flutter.buildConfigorAssetManifest.bin.json) before user code executes. - Ensure resolution is idempotent for already-hashed DPR variants produced by
AssetImage.
- In
- 100% Asset Directory Immutability:
- Remove exclusions in
packages/flutter_tools/lib/src/web/content_hash.dartforshaders/,NOTICES, andNOTICES.Z, hashing them on disk along withAssetManifest.bin.jsonandFontManifest.json. - Pass manifest hashes via
_flutter.buildConfiginflutter_bootstrap.jsso all files underbuild/web/assets/can be served withCache-Control: max-age=31536000, immutable.
- Remove exclusions in
- Un-hide
--web-content-hash:- Remove
hide: truefromWebOptions.webContentHashinpackages/flutter_tools/lib/src/web/web_options.dartonce runtime resolution and manifest immutability pass browser integration verification.
- Remove
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with engine/src/flutter/lib/web_ui/AssetManager and initialization.dart, then inspect packages/flutter_tools/lib/src/web/content_hash.dart and web_options.dart. Trace initializeEngineServices() and flutter_bootstrap.js buildConfig handling before changing runtime and build behavior. Done means raw asset keys resolve to hashed paths, the listed asset files are hashed and immutable, --web-content-hash is visible, and browser integration verification passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, javascript
- Domain
- build-system, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100