[Webkit-unassigned] [Bug 58391] New: Embedded font resources never get released when page is closed
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Apr 12 16:10:43 PDT 2011
https://bugs.webkit.org/show_bug.cgi?id=58391
Summary: Embedded font resources never get released when page
is closed
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: Linux
Status: UNCONFIRMED
Severity: Major
Priority: P2
Component: WebKit Gtk
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: ihaohu at gmail.com
This should happen on all WebKit ports which using CAIRO as rendering engine.
I observed both latest WebKitGTK+ and Google Chrome Official release on Linux.
How to reproduce:
Open browser, load a page with embedded font, (e.g. the simple test page attached),
refresh the page many times, observing the memory usage of the process.
e.g. For Google Chrome on Linux, loading the attached page, then about 20~30M of memory will be used. But if refreshing the page many times, you can easily see the memory usage will rock climbing.
Why it happens like that?
http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
The intention here to set destroy function to both [buffer] & [freeTypeFace] by using cairo_font_face_set_user_data() are great.
But they never get called even when the page is closed.
>From my understanding, to render the embedded font:
(1) [SharedBuffer] contains the embedded font data
(2) based on [SharedBuffer], a Freetype Face is created [FT_Face] by FT_New_Memory_Face()
(3) based on [freeTypeFace], a [cairo_font_face_t] is created by cairo_ft_font_face_create_for_ft_face()
(4) based on the [cairo_font_face_t], a [cairo_scaled_font_t] is created by cairo_scaled_font_create() in FontPlatformDataFreeType.cpp, cairo_scaled_font_create() also add a ref count on [cairo_font_face_t]
(5) The [cairo_scaled_font_t] is the actually font object that will be used for rendering
Ideally, since the release should happen like:
(a) [cairo_scaled_font_t] should be released by cairo_scaled_font_destroy() in it's deconstructor, which will also decrease the ref count of [cairo_font_face_t]
(b) [cairo_font_face_t] should be released by cairo_font_face_destroy() in it's deconstructor while (a) is done
(c) [FT_Face] and [SharedBuffer] should both get release when (b) is done, since they are registered by cairo_font_face_set_user_data()
BUT, since CAIRO choose to do cache internally, right after cairo_scaled_font_create() is called, the reference count of [cairo_font_face_t] will be 2. And due to that, nothing will get released since they reference count won't be 0.
I personally don't have a good solution since I don't want to change anything inside Cairo library. To provide myself a workaround, I just remember all the [SharedBuffer] and [FT_Face] that get created for a particular URI, and when the URI changes to another one, I'll release those 2 anyway.
Please help to see if there is any better solution. Thanks a lot.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list