flutter / flutter/flutter

[web] Support runtime content-hashed asset resolution in web_ui and un-hide --web-content-hash

Open
#193,031 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

platform-web team-web
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
  1. Web Engine Runtime Asset Resolution (ui_web.AssetManager):
    • In engine/src/flutter/lib/web_ui/, teach ui_web.AssetManager to resolve raw logical keys (assets/data/config.json) to content-hashed paths synchronously via AssetManager.getAssetUrl(asset).
    • In initialization.dart, ingest the key-to-hash mapping during initializeEngineServices() (via _flutter.buildConfig or AssetManifest.bin.json) before user code executes.
    • Ensure resolution is idempotent for already-hashed DPR variants produced by AssetImage.
  2. 100% Asset Directory Immutability:
    • Remove exclusions in packages/flutter_tools/lib/src/web/content_hash.dart for shaders/, NOTICES, and NOTICES.Z, hashing them on disk along with AssetManifest.bin.json and FontManifest.json.
    • Pass manifest hashes via _flutter.buildConfig in flutter_bootstrap.js so all files under build/web/assets/ can be served with Cache-Control: max-age=31536000, immutable.
  3. Un-hide --web-content-hash:
    • Remove hide: true from WebOptions.webContentHash in packages/flutter_tools/lib/src/web/web_options.dart once runtime resolution and manifest immutability pass browser integration verification.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.