-
Notifications
You must be signed in to change notification settings - Fork 6k
download fonts concurrently with wasm #36813
download fonts concurrently with wasm #36813
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
harryterkelsen
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.
You should check that the fonts are downloaded early when using the HTML renderer as well (--web-renderer=html).
I think the FontCollection interface is overdue for a refactoring since the names of the methods don't match what is actually happening.
The new FontCollection should contain:
loadFontFromList: this is required since Flutter gives developers an API to load a new font. This needs to beFuture<void>because the HTML font collection uses an API which isFuturedownloadAssetFonts: this should beFuture<void>and complete when all of the fonts which are read from theFontManifest.jsonhave been downloaded.debugDownloadTestFonts: does whatdebugRegisterTestFontsdoes now.registerDownloadedFonts: In this step you register all of the fonts which were downloaded indownloadAssetFontswith the renderer (in the CanvasKit case, this is where you make theSkTypefaceand register it with theTypefaceFontProvider. I don't think this needs to beFuture<void>, it could probably just bevoid.
During initialization you would do Future.wait([initializeRenderer, fontCollection.downloadAssetFonts]) and then after that call registerDownloadedFonts.
90de99f to
347acef
Compare
2cc506c to
2126463
Compare
harryterkelsen
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.
Needs more work to fix polyfill version
|
Gold has detected about 2 new digest(s) on patchset 4. |
|
Gold has detected about 2 new digest(s) on patchset 5. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
harryterkelsen
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.
Mostly LGTM just one more change
harryterkelsen
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
refactored
FontCollectionfor both canvaskit and html.With the refactor, it becomes possible to download fonts concurrently with wasm, resolving issue: flutter/flutter#105929
fontCollection refactor
Each font needs to be 1) downloaded and 2) registered before it can be used.
Previously, this process was done in one function call:
registerFonts()Now, downloading fonts happens in two separate function calls:
downloadAsetFonts(AssetManager assetmanager)to download fontsregisterDownloadedFonts()to register fontsBreaking the previous
registerFonts()into the two aforementioned steps allows the following functions to be called concurrently:downloadAsetFonts(AssetManager assetmanager)canvaskit = await downloadCanvasKit()All affected tests were refactored as well.
Before:

After:

Pre-launch Checklist
writing and running engine tests.
///).