RESOLVED INVALID Bug 54758
Crash when laying out page with loaded fonts (intermittent)
https://bugs.webkit.org/show_bug.cgi?id=54758
Summary Crash when laying out page with loaded fonts (intermittent)
Russell Brenner
Reported 2011-02-18 11:00:47 PST
When laying out a page that uses a downloaded font, preliminary layout is performed using the appropriate fallback font (default serif, sans, or monotype). The download does not start until the first use of the font. When the download completes, CSSFontSelector::fontLoaded() calls Document::scheduleForcedStyleRecalc() to notify of the switch from the fallback to the actual font. Also upon completion of the download, CSSFontFaceSource::fontLoaded() and CSSSegmentedFontFace::fontLoaded() have been calling pruneTable(), which immediately wipes out associated GlyphPageTreeNodes. The problem is that those GlyphPageTreeNodes, the ones associated with the fallback font, may still be in use on the UI thread, frequently by Font::glyphDataForCharacter(), causing a segfault.
Attachments
proposed patch (1.30 KB, patch)
2011-02-18 11:08 PST, Russell Brenner
eric: review-
stack trace (17.53 KB, text/plain)
2011-02-22 11:23 PST, Russell Brenner
no flags
proposed patch (3.20 KB, patch)
2011-02-24 10:59 PST, Russell Brenner
no flags
proposed patch (3.21 KB, patch)
2011-02-24 11:18 PST, Russell Brenner
no flags
Russell Brenner
Comment 1 2011-02-18 11:08:32 PST
Created attachment 82984 [details] proposed patch This patch simply removes the calls to pruneTable() at the moment that the font download is completed, deferring pruning until destruction of the owner. Element::recalcStyle triggers ~Font, which leads to FontCache::removeClient, which leads to ~CSSSegmentedFontFace and ~CSSFontFaceSource, each of which calls pruneTable at a time when it appears safe to do so. This patch is #ifdef'ed for Android, but I believe it to be safe for all platforms.
Alexey Proskuryakov
Comment 2 2011-02-18 20:27:03 PST
Could you please attach a crash log, <http://www.webkit.org/quality/crashlogs.html>? I don't understand why this bug says "Platform: Android", but the patch targets every other platform except for Android.
Russell Brenner
Comment 3 2011-02-22 11:23:59 PST
Created attachment 83347 [details] stack trace Attaching stack trace of a typical failure. Here's an excerpt showing the fallout of a freed node pointer: (gdb) frame 1 #1 0x822530a6 in WebCore::Font::glyphDataForCharacter (this=0x78d7f4, c=69, mirror=false, forceSmallCaps=false) at external/webkit/WebCore/platform/graphics/FontFastPath.cpp:76 76 GlyphData data = page->glyphDataForCharacter(c); (gdb) l 71 if (!useSmallCapsFont) { 72 // Fastest loop, for the common case (not small caps). 73 while (true) { 74 page = node->page(); 75 if (page) { 76 GlyphData data = page->glyphDataForCharacter(c); 77 if (data.fontData) { 78 if (data.fontData->platformData().orientation() == Vertical && data.fontData->orientation() == Horizontal && Font::isCJKIdeograph(c)) { 79 const SimpleFontData* ideographFontData = data.fontData->brokenIdeographFontData(); 80 GlyphPageTreeNode* ideographNode = GlyphPageTreeNode::getRootChild(ideographFontData, pageNumber); (gdb) p page $1 = (WebCore::GlyphPage *) 0x9 With the proposed patch, these two calls pruneTable() remain in place for all platforms except android (#if ! PLATFORM(ANDROID)). This may be overly conservative, as I believe the pruning will still take place in a timely fashion when the page is updated in response to Document::scheduleForcedStyleRecalc(), called by CSSFontSelector::fontLoaded(). The more aggressive patch would be to remove these two calls from all platforms.
Eric Seidel (no email)
Comment 4 2011-02-24 02:47:08 PST
Comment on attachment 82984 [details] proposed patch This is really really really scary. No changelog = r-.
Russell Brenner
Comment 5 2011-02-24 10:59:15 PST
Created attachment 83678 [details] proposed patch Added missing ChangeLogs
WebKit Review Bot
Comment 6 2011-02-24 11:02:54 PST
Attachment 83678 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'ChangeLog', u'Source/WebCore/ChangeLog', u..." exit_code: 1 ChangeLog:6: Line contains tab character. [whitespace/tab] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Russell Brenner
Comment 7 2011-02-24 11:18:52 PST
Created attachment 83684 [details] proposed patch cleaned up rogue tab
Russell Brenner
Comment 8 2011-02-28 09:53:30 PST
Pinging for review
Russell Brenner
Comment 9 2011-03-01 13:42:47 PST
Added oliver (original author) to cc list
Oliver Hunt
Comment 10 2011-03-01 13:46:52 PST
Did you mean a different oliver?
Russell Brenner
Comment 11 2011-03-01 16:27:13 PST
Must be, if this code doesn't look familiar. I pulled the name oliver from http://trac.webkit.org/changeset/26484 and didn't catch that it mapped to :olliej. Sorry 'bout that. AFAICT, it looks like :oliver is no longer active.
Oliver Hunt
Comment 12 2011-03-01 16:31:36 PST
After some digging it looks like svn history has been borken somehow -- it's definitely referring to me but it's all hyatt's fault.
Oliver Hunt
Comment 13 2011-03-01 16:32:27 PST
it == the revision that introduced css fontface. According to the changelog hyatt did it (look changelog being more helpful/correct than revision history!!! hah!)
Russell Brenner
Comment 14 2011-03-02 09:55:08 PST
Thanks for sleuthing that. Haven't connected with hyatt yet via irc; will try smtp.
Russell Brenner
Comment 15 2011-03-17 15:00:06 PDT
Underlying issue was traced to skia font matching for custom fonts with bold or italic style. Resolution was found in platform code.
Eric Seidel (no email)
Comment 16 2011-03-22 15:06:13 PDT
Comment on attachment 83684 [details] proposed patch Cleared review? from attachment 83684 [details] so that this bug does not appear in http://webkit.org/pending-review. If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).
Naveen Bobbili
Comment 17 2012-02-29 00:45:59 PST
Is there any update on this? I have recently come accross the same issue when running webcrawler test on motorola devices.
Note You need to log in before you can comment on or make changes to this bug.