Closed Bug 1480615 Opened 2 years ago Closed 2 years ago
Reuse scaled fonts across blob item recordings
For each piece of SVG text we record a new scaled font. This can be quite wasteful in recording size and time.
An idea of how to do this is to add a shared section to blob recordings. This could contain all of the scaled fonts, unscaled fonts and even source surfaces. Items would include a list of all the shared items that they depend on and the blob merging would only copy over the dependencies needed.
I would prefer if we could somehow hook into wr's "native" font management since this has historically been messy and bug-ridden.
(In reply to Alexis Beingessner [:Gankro] from comment #2) > I would prefer if we could somehow hook into wr's "native" font management > since this has historically been messy and bug-ridden. Note this is not about sharing fonts between blobs. Just between the different recordings in the same blob.
I have an idea for how to make sharing work even across separate blobs. I will try to implement it and see if it turns into something worth committing.
Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Added a query for getting font instance data out of WR in PR https://github.com/servo/webrender/pull/3002 This will be used later for solving this.
See Also: → https://github.com/servo/webrender/pull/3002
The kernel idea here is that we send over all ScaledFonts used in a blob images as WR FontInstances. Then all the blob image has to do is query that FontInstance data to recreate a ScaledFont if necessary, which will stick around for the rest of the lifetime of the FontInstance. This allows the ScaledFont to not only be reused across recordings within a blob image, but across any number of blob images that share the same ScaledFont. The advantage of this approach is that creation/deletion of these ScaledFonts are properly synchronized with blob image creation/deletion, because it all gets processed on the WR thread with normal FontInstance management. We don't have to add any extra bookkeeping on the content side to track lifetimes either because all our existing FontInstance handling takes care of that.
Attachment #9005666 - Flags: review?(jmuizelaar)
Comment on attachment 9005666 [details] [diff] [review] reuse scaled fonts across blob image recordings Review of attachment 9005666 [details] [diff] [review]: ----------------------------------------------------------------- I like it.
Attachment #9005666 - Flags: review?(jmuizelaar) → review+
Depends on: 1488887
Pushed by email@example.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/ada6c9fc290c reuse scaled fonts across blob image recordings. r=jrmuizel
You need to log in before you can comment on or make changes to this bug.