Skip to content

Conversation

@andrewkolos
Copy link
Contributor

@andrewkolos andrewkolos commented Jan 23, 2024

Part of work on #141194

The AssetBundle class contains two members, entries and entryKinds. entries contains asset data indexed by asset key. entryKinds contains the "kinds" of these assets, again indexed by asset key.

Change. Rather than have two separate maps, this PR proposes combining these maps into one by wrapping the asset data and kind into a single data type AssetBundleEntry.

Purpose. In #141194, I am considering associating more information with an asset. In particular, what transformers are meant to be applied to it when copying it to the build output. Rather than adding another map member onto AssetBundle (e.g. entryTransformers), I decided to make things neater by introducing the AssetBundleEntry type.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jan 23, 2024
final DevFSContent content;
final AssetKind kind;

Future<List<int>> contentsAsBytes() => content.contentsAsBytes();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DevFSContent::contentsAsBytes is called so often that I decided to expose a convenience getter for it.

Copy link
Contributor

@christopherfujino christopherfujino Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it up to you, but my personal preference is against these kinds of convenience methods, as they improve the efficiency of writing code at the cost of reading it (I find myself jumping to definition when I'm debugging and see a function like this, fearing it might be a 200 liner with complex error handling).

@immutable
final class AssetBundleEntry {
const AssetBundleEntry(this.content, {
this.kind = AssetKind.regular,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssetKind.regular was used as a default in a few different places, so I decided to make it a default here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we at least add a dartdoc to AssetKind.regular--I don't personally know what a "regular" asset is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the more I think about this, the more I worry we introduce bugs where we accidentally let this fall back AssetKind.regular. Can you convince me otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that a "regular" asset is simply what it isn't—a font, shader, or model. I can document that, but I don't know if negative definitions are particularly helpful.

Copy link
Contributor Author

@andrewkolos andrewkolos Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the more I think about this, the more I worry we introduce bugs where we accidentally let this fall back AssetKind.regular. Can you convince me otherwise?

No, to be honest. Parameters with default values always risk this as a tradeoff for less noise throughout the rest of the code. I'm happy to make it required. I originally opted not to for the initial PR review since it would have made the diff more intimidating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that a "regular" asset is simply what it isn't—a font, shader, or model. I can document that, but I don't know if negative definitions are particularly helpful.

Interesting, so it basically means "just copy, don't do any pre-processing"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, what's a model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so it basically means "just copy, don't do any pre-processing"?

Yeah, my hope is that the docstring for AssetBundleEntry alludes-to/implies this.

As an example, you can see this stuff in devfs.dart.

also, what's a model?

A file containing data for a 3D model, I believe.

@andrewkolos andrewkolos marked this pull request as ready for review January 23, 2024 07:33
@andrewkolos andrewkolos changed the title consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type AssetBundleEntry consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type, AssetBundleEntry Jan 23, 2024
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, my only real concern is whether allowing AssetBundleEntry(kind: ...) to be optional is a footgun.

@christopherfujino
Copy link
Contributor

Also, this is a great refactor!

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 23, 2024
@auto-submit auto-submit bot merged commit cbe0cea into flutter:master Jan 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 24, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 24, 2024
flutter/flutter@5b673c2...19b06f4

2024-01-24 [email protected] Roll Flutter Engine from 7c592dbfa032 to ba3a70ce7722 (2 revisions) (flutter/flutter#142130)
2024-01-24 [email protected] Roll Flutter Engine from 700235c85d4a to 7c592dbfa032 (2 revisions) (flutter/flutter#142108)
2024-01-24 [email protected] Roll Flutter Engine from da96f9de3f69 to 700235c85d4a (1 revision) (flutter/flutter#142100)
2024-01-24 [email protected] Roll Flutter Engine from 220416cfa6ca to da96f9de3f69 (5 revisions) (flutter/flutter#142098)
2024-01-24 [email protected] Don't change the height of the Textfield's labelStyle when it focused. (flutter/flutter#141943)
2024-01-24 [email protected] Ignore a leak. (flutter/flutter#141737)
2024-01-24 [email protected] [github actions] FINALLY fix the mysterious token error in github actions (flutter/flutter#142058)
2024-01-24 [email protected] Revert "Add abifilters to our gradle templates" (flutter/flutter#142089)
2024-01-23 [email protected] Roll Flutter Engine from 0b9b538bd458 to 220416cfa6ca (2 revisions) (flutter/flutter#142079)
2024-01-23 [email protected] Add abifilters to our gradle templates (flutter/flutter#135529)
2024-01-23 [email protected] Roll Flutter Engine from 11a16d83ab6c to 0b9b538bd458 (2 revisions) (flutter/flutter#142076)
2024-01-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.2.0 to 4.3.0 (flutter/flutter#142075)
2024-01-23 [email protected] consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type, `AssetBundleEntry` (flutter/flutter#142029)
2024-01-23 [email protected] Roll Flutter Engine from 57d6b518f920 to 11a16d83ab6c (4 revisions) (flutter/flutter#142071)
2024-01-23 [email protected] Roll Flutter Engine from 994054143fc3 to 57d6b518f920 (3 revisions) (flutter/flutter#142067)
2024-01-23 [email protected] [flutter_tools] fix language_version_test and enable shuffle (flutter/flutter#142009)
2024-01-23 [email protected] Merge flutter_goldens_client into flutter_goldens (flutter/flutter#141900)
2024-01-23 [email protected] Allow overriding the native assets yaml file in the resident runner. (flutter/flutter#142016)
2024-01-23 [email protected] Roll Flutter Engine from b229878c57f5 to 994054143fc3 (1 revision) (flutter/flutter#142059)
2024-01-23 [email protected] Update material banner maxScaleFactor to meet GAR requirement  (flutter/flutter#142015)
2024-01-23 [email protected] Add tooltip for the clear button on `SearchAnchor`'s search view (flutter/flutter#141804)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@andrewkolos andrewkolos deleted the consolidate-entries-and-entry-kinds branch April 29, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants