Closed Bug 1595768 Opened 5 years ago Closed 4 years ago

Investigate why we rasterize glyphs so often

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed
firefox76 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

We rasterize a few glyphs almost every frame even when it doesn't look like text is changing on the page.

For example while watching a youtube video I see 4 glyphs rasterized every frame.

It looks like we can easily get into a loop of requesting a few glyphs which error during rasterization for some reason, and re-request them every frame.

I added some log and I am getting this continuously without having to go further than the tiles from about:newtab.

!! Error for key GlyphKey(3)
!! Error for key GlyphKey(536870915)
!! Error for key GlyphKey(268435459)
>> rasterize glyphs [GlyphKey(3), GlyphKey(536870915)]
>> rasterize glyphs [GlyphKey(268435459)]
!! Error for key GlyphKey(3)
!! Error for key GlyphKey(536870915)
!! Error for key GlyphKey(268435459)
>> rasterize glyphs [GlyphKey(3), GlyphKey(536870915)]
>> rasterize glyphs [GlyphKey(268435459)]
!! Error for key GlyphKey(3)
!! Error for key GlyphKey(536870915)
!! Error for key GlyphKey(268435459)
>> rasterize glyphs [GlyphKey(3), GlyphKey(536870915)]
>> rasterize glyphs [GlyphKey(268435459)]
!! Error for key GlyphKey(268435459)
!! Error for key GlyphKey(3)
!! Error for key GlyphKey(536870915)
>> rasterize glyphs [GlyphKey(3), GlyphKey(536870915)]
>> rasterize glyphs [GlyphKey(268435459)]
``

What's particularly bad about this is that it causes us to block on rayon for nothing which takes a millisecond or more from our precious frame budget.
Assignee: nobody → nical.bugzilla

The problem partly has to do with how eagerly we evict glyph cache entries with no size (which is what happens for errored glyphs). We should only evict them when they haven't been requested for a number of frame to avoid continuously requesting them each frame.

Attachment #9115474 - Attachment is obsolete: true
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0112c670bd65
Keep empty items in the texture cache. r=gw
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73

Hey Nical! I was helping someone fix a bug in Servo where Servo was uploading a 0x0 image to WR which causes a panic due to a an invalid cache texture lookup. (https://searchfox.org/mozilla-central/source/gfx/wr/webrender/src/texture_cache.rs#164, https://searchfox.org/mozilla-central/source/gfx/wr/webrender/src/renderer.rs#3648)

This happens because empty entries are given an invalid texture cache id. I ran into this patch, and was puzzled that Firefox isn't also hitting this same cache texture lookup panic in the case of invalid glyphs, but I think its because this wasn't entirely fixed.

Gecko doesn't create texture cache entries for invalid/zero-sized glyphs: https://searchfox.org/mozilla-central/rev/3a9dbc403f33cca1ff43326d78340add7d996350/gfx/wr/webrender/src/glyph_rasterizer/mod.rs#213-216

It looks like an earlier revision you made invalid/zero-sized glyphs create a texture cache entry, but that bit was removed in the final revision (earlier revision: https://phabricator.services.mozilla.com/D56938).

I could be missing something, but from a bit of testing it looks like invalid glyphs are still getting a rasterization request every frame.

Flags: needinfo?(nical.bugzilla)

Indeed that's very odd.

Status: RESOLVED → REOPENED
Flags: needinfo?(nical.bugzilla)
Resolution: FIXED → ---

This was added in a previous patch but it seems that we don't need it if invalid glyphs can be treated as blank glyph cache items.

Depends on D68857

Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f777b2dc1223
Don't evict blank glyphs to avoid re-rasterizing them continuously. r=gw
https://hg.mozilla.org/integration/autoland/rev/e3f5c752e57f
Don't track empty items in the texture cache. r=gw
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: