Skip to content

[tracking] Speed up asset manifest loading and parsing #117228

@andrewkolos

Description

@andrewkolos

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 produce AssetManifest.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.json1

Footnotes

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

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: assetsPackaging, accessing, or using assetsframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions