From 2205a68599a12be7678e5d361d8574c1e6908f8f Mon Sep 17 00:00:00 2001 From: "levin@chromium.org" Date: Fri, 27 May 2011 02:16:21 +0000 Subject: [PATCH] 2011-05-26 David Levin Reviewed by Dmitry Titov. WebKit's font notification has problems when the WebKit main thread != UI thread. https://bugs.webkit.org/show_bug.cgi?id=61391 This doesn't happen in DumpRenderTree, so it needs a unit test which is taking me some time to write correctly. In the meantime, this issues happens to be causing some crashes in Chrome so here's the fix alone for the time being. * platform/graphics/mac/FontCacheMac.mm: (WebCore::invalidateFontCache): Ensure that FontCache::invalidate is only called on WebKit's main thread. (WebCore::fontCacheRegisteredFontsChangedNotificationCallback): Call common function for font cache invalidation. Note that the call to fontCache() is fine since the singleton is initialized well before calling this function. Theoretically, there could be a problem due to a lack of a memory barrier but that is highly unlikely and this is debug only code. (WebCore::fontCacheATSNotificationCallback): Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87462 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 ++++++++++++++++++ Source/WebCore/platform/graphics/mac/FontCacheMac.mm | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f232002..c4e7ad4 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2011-05-26 David Levin + + Reviewed by Dmitry Titov. + + WebKit's font notification has problems when the WebKit main thread != UI thread. + https://bugs.webkit.org/show_bug.cgi?id=61391 + + This doesn't happen in DumpRenderTree, so it needs a unit test which is taking me + some time to write correctly. In the meantime, this issues happens to be causing + some crashes in Chrome so here's the fix alone for the time being. + + * platform/graphics/mac/FontCacheMac.mm: + (WebCore::invalidateFontCache): Ensure that FontCache::invalidate is only called on WebKit's main thread. + (WebCore::fontCacheRegisteredFontsChangedNotificationCallback): Call common function for font cache invalidation. + Note that the call to fontCache() is fine since the singleton is initialized well before calling this function. Theoretically, + there could be a problem due to a lack of a memory barrier but that is highly unlikely and this is debug only code. + (WebCore::fontCacheATSNotificationCallback): Ditto. + 2011-05-26 Stephanie Lewis Reviewed by Geoff Garen. diff --git a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm index c71c411..9f5c44e 100644 --- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm +++ b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm @@ -36,22 +36,33 @@ #import "WebCoreSystemInterface.h" #import "WebFontCache.h" #import +#import #import namespace WebCore { +// The "void*" parameter makes the function match the prototype for callbacks from callOnMainThread. +static void invalidateFontCache(void*) +{ + if (!isMainThread()) { + callOnMainThread(&invalidateFontCache, 0); + return; + } + fontCache()->invalidate(); +} + #if !defined(BUILDING_ON_LEOPARD) static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) { ASSERT_UNUSED(observer, observer == fontCache()); ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotification)); - fontCache()->invalidate(); + invalidateFontCache(0); } #else static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*) { - fontCache()->invalidate(); + invalidateFontCache(0); } #endif -- 2.7.4