diff --git a/src/ports/SkFontMgr_android_ndk.cpp b/src/ports/SkFontMgr_android_ndk.cpp index 45088cffb1..289c0a1bdb 100644 --- a/src/ports/SkFontMgr_android_ndk.cpp +++ b/src/ports/SkFontMgr_android_ndk.cpp @@ -722,7 +722,9 @@ public: uint32_t fHash; }; sk_sp find(const Request& request) { - SkAutoSharedMutexShared lock(fMutex); + // SkLRUCache::find() mutates the LRU list (remove + addToHead) on a + // cache hit, so it must be guarded by the exclusive lock. + SkAutoSharedMutexExclusive lock(fMutex); sk_sp* typeface = fRequests.find(request); if (typeface) { return *typeface; @@ -773,7 +775,9 @@ public: uint32_t fHash; }; sk_sp find(const Match& match) { - SkAutoSharedMutexShared lock(fMutex); + // SkLRUCache::find() mutates the LRU list (remove + addToHead) on a + // cache hit, so it must be guarded by the exclusive lock. + SkAutoSharedMutexExclusive lock(fMutex); sk_sp* typeface = fMatches.find(match); if (typeface) { return *typeface;