Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewkolos opened this issue Dec 16, 2022 · 4 comments
Closed

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

andrewkolos opened this issue Dec 16, 2022 · 4 comments
Assignees
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

Comments

@andrewkolos
Copy link
Contributor

andrewkolos commented Dec 16, 2022

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.

@andrewkolos andrewkolos added tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. a: assets Packaging, accessing, or using assets labels Dec 16, 2022
@andrewkolos andrewkolos self-assigned this Dec 16, 2022
@goderbauer goderbauer added the P1 High-priority issues at the top of the work list label Dec 20, 2022
@andrewkolos andrewkolos added P3 Issues that are less important to the Flutter project and removed P1 High-priority issues at the top of the work list labels Mar 7, 2023
@andrewkolos
Copy link
Contributor Author

An update since it has been a while: I still plan on starting the deprecation process soonTM.

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
@feinstein
Copy link
Contributor

feinstein commented Sep 6, 2023

Will this solve the "blinking" problem we see when loading an image from assets?

Many people use the AssetManifest.json to pre-cache all images into memory and avoid images/SVG suddenly appearing on screen. So if pre-cache will still be needed, then it would be nice to have helper functions to traverse that binary file.

@andrewkolos
Copy link
Contributor Author

Will this solve the "blinking" problem we see when loading an image from assets?

Many people use the AssetManifest.json to pre-cache all images into memory and avoid images/SVG suddenly appearing on screen. So if pre-cache will still be needed, then it would be nice to have helper functions to traverse that binary file.

Oh, I'm sorry, this issue should have been closed as completed by #122505 long ago.
This change made it into the 3.7 release, if I recall correctly, so if you have seen image loading jank since then, it's probably still an issue. You may want to file an issue if one isn't already open on the subject.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

3 participants