Closed Bug 1480615 Opened 2 years ago Closed 2 years ago

Reuse scaled fonts across blob item recordings

Categories

(Core :: Graphics: WebRender, enhancement, P3)

63 Branch
enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox63 --- wontfix
firefox64 --- fixed

People

(Reporter: jrmuizel, Assigned: lsalzman)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [gfx-noted])

Attachments

(1 file)

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.
Priority: -- → P3
Whiteboard: [gfx-noted]
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.
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+
No longer depends on: 1488887
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ada6c9fc290c
reuse scaled fonts across blob image recordings. r=jrmuizel
Blocks: 1474180
https://hg.mozilla.org/mozilla-central/rev/ada6c9fc290c
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Depends on: 1489170
You need to log in before you can comment on or make changes to this bug.