Skip to content

Speed up transforming assets #168629

@Albert221

Description

@Albert221

Hey!

In our project, we have a Design System package with many many icons, the SVG files. We wanted to use the vector_graphics_compiler to transform them into compiled form and save on SVG parsing on the device, but there is one problem.

The asset transformation happens for every flutter run for every asset. It's not cached in the build/ directory or anything like that. Transforming them once takes a good 5-10 minutes (on a not-bad M1 Pro MacBook). Well, that's the cost of this transformation, sure. But if the assets were cached, and e.g. their checksum checked first if they're not already transformed, it would save this time on hot-reloads, consequent builds/runs, and also we could put this cache directory under cache on CI/CD. Right now it's unusable with asset transformers.

The flutter_tool also spawns a big amount of processes to run on each asset. Maybe that could be optimized somehow to run as many as the machine's CPU has or something along these lines, if that could help the performance. The other solution would be to support transforming whole directories (which we too can pass in assets in pubspec, not only files one by one), so that the flutter_tool would spawn one process per asset definition and not file, hence saving at least on spinning-up the Dart executable and the script. That would of course also require a change of the specification of executables for transformers and a change in vector_graphics_compiler package. Just thinking out loud.

Image

Thanks

Flutter 3.29.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ea121f8859 (4 weeks ago) • 2025-04-11 19:10:07 +0000
Engine • revision cf56914b32
Tools • Dart 3.7.2 • DevTools 2.42.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: assetsPackaging, accessing, or using assetsteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions