New issue
Advanced search Search tips

Issue 721973 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

FontFaceCache is never cleared in renderers

Project Member Reported by ssid@chromium.org, May 13 2017

Issue description

FontFaceCache keeps growing on navigating to multiple pages on the same site. Attached a trace where the font resources grew upto 10MB.

Can we clear these resources?
 
browse_news_globo02017-05-12_14-09-03.html
5.2 MB View Download

Comment 1 by ssid@chromium.org, May 13 2017

Labels: Performance-Memory
Cc: keishi@chromium.org tasak@google.com

Comment 3 by keishi@chromium.org, May 14 2017

I was able to reproduce the results.

From the Blink side it looks FontCustomPlatformData is destructed earlier. But it looks like the decoded font data inside SkTypeface is somehow still alive.

I need to look at how SkTypeface is retained. Does anyone know about this?
Cc: drott@chromium.org
drott@: Do you have any insights on this?

Comment 5 by ssid@chromium.org, May 14 2017

From what I read in the code, it looked like FontFaceCache holds references to the type faces in one of the font fact lists.

Comment 6 by bashi@chromium.org, May 15 2017

IIUC we also need to purge skia's font cache in addition to FontCache. RenderThreadImpl::ClearMemory() does the job but we only call it under memory pressure.

Comment 7 by drott@chromium.org, May 15 2017

I would not say I have insights exactly, but I am aware that our font handle lifecycles need improvement. I have a TODO item towards this end, and by that I mean mainly managing FontPlatformData and SimpleFontData objects better. 

The other bigger issue we have is that we do not have a good way to count whether we still need a font, e.g. if it's still DOM connected, or whether we can dispose of it. At this point, I think it's mainly Blink's responsibility to manage SkTypeface lifecycles right, before we dig for further savings below the SkTypeface API.

Too early font cache purging of course is not the solution either, since decompression of a web font, parsing and glyph rasterization are costly operations.
So... what will be a next step action for this?

Comment 9 by drott@chromium.org, May 15 2017

 Issue 418929  is an enabling initial step, then we need to work on keeping a count of active font handles from the DOM or render tree.

Comment 10 by ssid@chromium.org, May 15 2017

Components: Blink>Fonts
I agree that it's Blink's responsibility to clear the SkTypeFace objects it keeps in cache. Can we have a simple solution there with limit on the size of the total size of FontFaceCache and evicting items based on an LRU list? do you think lru would be a good way to tell if we still need a font face?

Comment 11 by e...@chromium.org, May 15 2017

Owner: drott@chromium.org
Status: Assigned (was: Untriaged)

Comment 12 by drott@chromium.org, May 16 2017

LRU may work, the problem is one step before: For LRU we need reliable information on how often a font is in-use or touched and when it is ageing and a candidate for cache eviction, and we need to ensure that the desctruction of a FontPlatformData object actually destroys the SkTypeface. 

At this point SimpleFontData and FontPlatformData (which owns the SkTypeface) have cyclic ownership ties and I think this needs to be cleaned up first before we can apply a LRU strategy on these objects.

Sign in to add a comment