gfxDWriteFont::MeasureGlyphWidth() can be really slow

RESOLVED FIXED in Firefox 56

Status

()

Core
Graphics: Text
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: Ehsan, Assigned: jfkthame)

Tracking

unspecified
mozilla56
Points:
---

Firefox Tracking Flags

(firefox56 fixed)

Details

(Whiteboard: [qf:p1][gfx-noted])

Attachments

(1 attachment)

(Reporter)

Description

a year ago
STR:

1. Load wwww.youtube.com
2. In the search field, enter mozilla
3. Press enter

In the page load that follows, this function can take 30ms. https://perfht.ml/2rgFYXU

This is a bug on the Quantum Release Criteria.  Milan, can you please find an owner?  Thanks!
Flags: needinfo?(milan)
(Reporter)

Updated

a year ago
Blocks: 1363335
Can you get better dwrite symbols? If they're not on the symbol server talk to :ted
(Assignee)

Comment 2

a year ago
There are a couple of things I think we could try here. First, newer versions of dwrite have an extended interface IDWriteFontFace1 that adds, among other things, GetDesignGlyphAdvances and GetGdiCompatibleGlyphAdvances methods. These are presumably cheaper to call than the Get*Metrics APIs we're using at the moment. We'd have to include a runtime check for the availability of this interface, though, as the original Win7 (and earlier) versions didn't have it.

Second, we currently get the advance for a single glyph at a time; we could investigate whether getting advances for a whole range of glyphs in a single call would be significantly cheaper. Depends what the per-call overhead is, compared to the per-glyph cost.

Probably worth doing some low-level instrumentation around the dwrite calls to find out what the perf characteristics are really like, and then choosing a strategy based on that.
Jonathan, are you the right person to look at this?  Any other qf:p1 competing for your attention?
Component: Graphics → Graphics: Text
Flags: needinfo?(milan) → needinfo?(jfkthame)
Whiteboard: [qf:p1] → [qf:p1][gfx-noted]
(Assignee)

Comment 4

a year ago
Well... yes, I've got some ongoing investigations of qf:p1 layout stuff as well, but I could probably look into this tomorrow... at least to figure out which direction(s) we should pursue.

If the final answer is that "dwrite can be slow", there may be a limit to what we can do here, but I'm hopeful that one or both of the ideas in comment 2 will provide at least some mitigation.
Assignee: nobody → jfkthame
Flags: needinfo?(jfkthame)
(Reporter)

Updated

a year ago
See Also: → bug 1366166
(Reporter)

Comment 5

a year ago
(In reply to Jeff Muizelaar [:jrmuizel] from comment #1)
> Can you get better dwrite symbols? If they're not on the symbol server talk
> to :ted

Filed bug 1366166.  I'd appreciate if someone else can follow up on it please.  I lag on responding to bugzilla and have a work week coming up next week which isn't helpful in expediting things!
(Assignee)

Comment 6

a year ago
Created attachment 8869802 [details] [diff] [review]
Use the IDWriteFontFace1 interface if available to get glyph advances from DirectWrite more cheaply

In my testing, I haven't seen times anywhere near as large as Ehsan's 30ms from comment 0, so it's unclear to me how frequently this can occur. Nevertheless, instrumenting around the DWrite calls confirms that the IDWriteFontFace1 APIs that only get glyph advance (instead of all the glyph metrics) typically take about half as long, so I think it's worth switching to the newer API when available. We're talking about timings in the region of a microsecond per glyph, though, so the difference will be completely lost in the noise in higher-level profiles.
Attachment #8869802 - Flags: review?(jmuizelaar)
(In reply to Jonathan Kew (:jfkthame) from comment #6)
> Created attachment 8869802 [details] [diff] [review]
> Use the IDWriteFontFace1 interface if available to get glyph advances from
> DirectWrite more cheaply
> 
> In my testing, I haven't seen times anywhere near as large as Ehsan's 30ms
> from comment 0...

I imagine Ehsan may have been working on the reference machine?
(Assignee)

Comment 8

a year ago
Jeff: review ping?
Flags: needinfo?(jmuizelaar)
Attachment #8869802 - Flags: review?(jmuizelaar) → review+
Flags: needinfo?(jmuizelaar) → needinfo?(jfkthame)
(Assignee)

Comment 9

a year ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/699ca92b32489325344a644f8081200276c50611
Bug 1365776 - Use the IDWriteFontFace1 interface if available to get glyph advances from DirectWrite more cheaply. r=jrmuizel
(Assignee)

Updated

a year ago
Flags: needinfo?(jfkthame)

Comment 10

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/699ca92b3248
Status: NEW → RESOLVED
Last Resolved: a year ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.