-
Notifications
You must be signed in to change notification settings - Fork 29.7k
consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type, AssetBundleEntry
#142029
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
consolidate AssetBundle::entries and AssetBundle::entryKinds into a new type, AssetBundleEntry
#142029
Conversation
| final DevFSContent content; | ||
| final AssetKind kind; | ||
|
|
||
| Future<List<int>> contentsAsBytes() => content.contentsAsBytes(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
AssetBundleEntryAssetBundleEntry
packages/flutter_tools/test/general.shard/asset_bundle_test.dart
Outdated
Show resolved
Hide resolved
christopherfujino
left a comment
There was a problem hiding this 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.
|
Also, this is a great refactor! |
…into a new type, `AssetBundleEntry` (flutter/flutter#142029)
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
Part of work on #141194
The
AssetBundleclass contains two members,entriesandentryKinds.entriescontains asset data indexed by asset key.entryKindscontains 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 theAssetBundleEntrytype.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.