Font loading
@corinnewo is already working on this.
Since Dec 14, 2021.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
When hitting a jig from an empty cache it takes a really long time till first paint. The main culprit is font loading... took a full 30 seconds for me.
Unfortunately, this is also a tricky problem to solve since the fonts do need to be loaded in order to display text properly, and we have very dynamic dependencies which determine the fonts that need to be loaded.
Fortunately, there is a way we can do this... very roughly:
- Extend the BodyExt trait with a
get_font_dependencies()method that returns the list of fonts - Default impl is an empty Vec
- Each module is responsible for returning the list - but, importantly, we can also add a method on the Sticker's Text data structure, which would also return a Vec of fonts, and card modules only need to know about their theme (and "mode" which is already provided)
Note that the BodyExt trait already has a method to get the current theme, though I am not entirely sure if this accounts for the jig theme- so get_font_dependencies() should probably take ThemeId as a parameter (e.g. so it can properly answer for H1, P2, etc.)
Effectively this means we only have to do the tough logic in two places as of now (on the Text object, crawling through the html, and card modules, using the mode + theme), and then it's very easy to get the full list of fonts used in every module.
As a bonus, this is basically a harder version of the requirements to get module text data as a source for search. That means once we have this, it's pretty trivial to make it possible for inner text content of cards, posters, etc. to feed low-relevancy search!
Anyway- once we have the font list, the current font loading logic could be moved around so that the jig data needs to be known before it starts font loading.
This is a significant amount of work, but I believe it is on the order of 1-3 real days, not weeks, and imho it would have a huge impact on UX. In all honesty, hate to say this, but I kinda see this as a complete showstopper and a hard requirement for initial release outside of testing where we can prep the cache... 30 seconds is a really long time.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.