Skip to content

Commit

Permalink
Manually invalidate the FontCache before clearing ThreadGlobalData.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=248502

Reviewed by Cameron McCormack.

Destructing the FontCache can recurse back into the ThreadGlobalData getter (to remove cached entries), so
we want to manually clear the FontCache before clearing the ThreadGlobalData pointer.

This also moves m_destroyed to earlier in the class, so it's guaranteed to be destructed after m_fontCache.

* Source/WebCore/platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::destroy):
* Source/WebCore/platform/ThreadGlobalData.h:
* Source/WebCore/platform/graphics/FontCache.h:

Canonical link: https://commits.webkit.org/257160@main
  • Loading branch information
mattwoodrow committed Nov 30, 2022
1 parent e113b29 commit 2d8a920
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Source/WebCore/platform/ThreadGlobalData.cpp
Expand Up @@ -51,6 +51,9 @@ ThreadGlobalData::~ThreadGlobalData() = default;

void ThreadGlobalData::destroy()
{
if (m_fontCache)
m_fontCache->invalidate();
m_fontCache = nullptr;
m_destroyed = true;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/ThreadGlobalData.h
Expand Up @@ -106,6 +106,8 @@ class ThreadGlobalData : public PAL::ThreadGlobalData {
FontCache* fontCacheIfNotDestroyed() { return m_destroyed ? nullptr : &fontCache(); }

private:
bool m_destroyed { false };

WEBCORE_EXPORT void initializeCachedResourceRequestInitiators();
WEBCORE_EXPORT void initializeEventNames();
WEBCORE_EXPORT void initializeQualifiedNameCache();
Expand All @@ -125,7 +127,6 @@ class ThreadGlobalData : public PAL::ThreadGlobalData {
#endif

bool m_isInRemoveAllEventListeners { false };
bool m_destroyed { false };

WEBCORE_EXPORT friend ThreadGlobalData& threadGlobalData();
};
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/graphics/FontCache.h
Expand Up @@ -195,8 +195,9 @@ class FontCache {
static bool configurePatternForFontDescription(FcPattern*, const FontDescription&);
#endif

private:
void invalidate();

private:
void releaseNoncriticalMemory();
void platformReleaseNoncriticalMemory();
void platformInvalidate();
Expand Down

0 comments on commit 2d8a920

Please sign in to comment.