Title: [286634] trunk/Source/WebCore
- Revision
- 286634
- Author
- hey...@apple.com
- Date
- 2021-12-07 17:35:15 -0800 (Tue, 07 Dec 2021)
Log Message
Move shouldAutoActivateFontIfNeeded knownFamilies cache to FontCache
https://bugs.webkit.org/show_bug.cgi?id=233749
Reviewed by Myles Maxfield.
With OffscreenCanvas, we can call shouldAutoActivateFontIfNeeded on a
worker thread, and the knownFamilies HashSet is not thread safe. Also,
the AtomStrings it stores are thread-specific. Move it to FontCache, so
each thread has its own set.
* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::shouldAutoActivateFontIfNeeded):
(WebCore::shouldAutoActivateFontIfNeeded): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (286633 => 286634)
--- trunk/Source/WebCore/ChangeLog 2021-12-08 01:32:10 UTC (rev 286633)
+++ trunk/Source/WebCore/ChangeLog 2021-12-08 01:35:15 UTC (rev 286634)
@@ -1,3 +1,20 @@
+2021-12-07 Cameron McCormack <hey...@apple.com>
+
+ Move shouldAutoActivateFontIfNeeded knownFamilies cache to FontCache
+ https://bugs.webkit.org/show_bug.cgi?id=233749
+
+ Reviewed by Myles Maxfield.
+
+ With OffscreenCanvas, we can call shouldAutoActivateFontIfNeeded on a
+ worker thread, and the knownFamilies HashSet is not thread safe. Also,
+ the AtomStrings it stores are thread-specific. Move it to FontCache, so
+ each thread has its own set.
+
+ * platform/graphics/FontCache.h:
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::FontCache::shouldAutoActivateFontIfNeeded):
+ (WebCore::shouldAutoActivateFontIfNeeded): Deleted.
+
2021-12-07 Devin Rousso <drou...@apple.com>
Add a `DOMPasteAccessCategory` to control which pasteboard the WebProcess is granted access to when pasting
Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (286633 => 286634)
--- trunk/Source/WebCore/platform/graphics/FontCache.h 2021-12-08 01:32:10 UTC (rev 286633)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h 2021-12-08 01:35:15 UTC (rev 286634)
@@ -374,6 +374,10 @@
static std::optional<ASCIILiteral> alternateFamilyName(const String&);
static std::optional<ASCIILiteral> platformAlternateFamilyName(const String&);
+#if PLATFORM(MAC)
+ bool shouldAutoActivateFontIfNeeded(const AtomString& family);
+#endif
+
Timer m_purgeTimer;
bool m_shouldMockBoldSystemFontForAccessibility { false };
@@ -389,6 +393,10 @@
RecursiveLock m_fontLock;
#endif
+#if PLATFORM(MAC)
+ HashSet<AtomString> m_knownFamilies;
+#endif
+
#if PLATFORM(COCOA)
ListHashSet<String> m_seenFamiliesForPrewarming;
ListHashSet<String> m_fontNamesRequiringSystemFallbackForPrewarming;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (286633 => 286634)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-12-08 01:32:10 UTC (rev 286633)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-12-08 01:35:15 UTC (rev 286634)
@@ -1338,23 +1338,15 @@
}
#if PLATFORM(MAC)
-static bool shouldAutoActivateFontIfNeeded(const AtomString& family)
+bool FontCache::shouldAutoActivateFontIfNeeded(const AtomString& family)
{
-#ifndef NDEBUG
- // This cache is not thread safe so the following assertion is there to
- // make sure this function is always called from the same thread.
- static Thread* initThread = &Thread::current();
- ASSERT(initThread == &Thread::current());
-#endif
-
- static NeverDestroyed<HashSet<AtomString>> knownFamilies;
static const unsigned maxCacheSize = 128;
- ASSERT(knownFamilies.get().size() <= maxCacheSize);
- if (knownFamilies.get().size() == maxCacheSize)
- knownFamilies.get().remove(knownFamilies.get().random());
+ ASSERT(m_knownFamilies.size() <= maxCacheSize);
+ if (m_knownFamilies.size() == maxCacheSize)
+ m_knownFamilies.remove(m_knownFamilies.random());
// Only attempt to auto-activate fonts once for performance reasons.
- return knownFamilies.get().add(family).isNewEntry;
+ return m_knownFamilies.add(family).isNewEntry;
}
static void autoActivateFont(const String& name, CGFloat size)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes