[tracking] Speed up asset manifest loading and parsing #117228
Labels
a: assets
Packaging, accessing, or using assets
framework
flutter/packages/flutter repository. See also f: labels.
P3
Issues that are less important to the Flutter project
team-framework
Owned by Framework team
tool
Affects the "flutter" command-line tool. See also t: labels.
triaged-framework
Triaged by Framework team
Uh oh!
There was an error while loading. Please reload this page.
This issue tracks development that will speed up asset manifest loading and parsing, which will in turn speed up the first asset load that a Flutter app performs.
This was originally intended to perform as one change (#113637), with followup clean-up/tech-debt then to follow (#114913). However, due to problems with specific g3 tests, this is being split up into smaller changes.
Background
When loading an asset for the first time, the framework has to load a file called the asset manifest, which contains information about assets available to the app (for example, where to find higher-resolution variants of images). This file is in the JSON format.
Reading the file from storage, decoding into UTF, and parsing it as JSON is generally slower than we'd like, especially since this is will all likely happen on first paint (since many apps include assets on their first screens).
The asset manifest (
AssetManifest.json
) is created at build time.Desired Change
The idea is to use a binary format rather than JSON for the asset manifest file. In particular, we'll use the standard_message_codec package for encoding the manifest at build time and decoding it at runtime. This new manifest will be stored in a new file,
AssetManifest.bin
. In addition, for decoding the binary message, we'll lazily put off typecasting until we read individual keys--avoiding upfront typecasting for all entries. This will achieve a significant speedup for first asset load, especially on less powerful devices.Tasks
[x] Update
flutter_tools
to produceAssetManifest.bin
. #117233[x] After that change rolls, update g3 tool code to produce
AssetManifest.bin
.[x] Add new framework API for consuming the asset manifest.
#118410#119277[x] Update framework to consume
AssetManifest.bin
#118782#121322#122505[ ] After a full deprecation cycle and process, remove tool code that generates
AssetManifest.json
1Footnotes
While AssetManifest.json is not officially documented, some users decided to depend on it based on recommendation from flutter developers. Removing it outright would break them. For example, Google Fonts reads it to determine whether or not a font can be loaded from the device rather than loading it over HTTP. ↩
The text was updated successfully, but these errors were encountered: