diff --git a/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift b/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift index e63867d987..11f729f869 100644 --- a/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift +++ b/lottie-swift/src/Public/AnimationCache/LRUAnimationCache.swift @@ -44,7 +44,10 @@ public class LRUAnimationCache: AnimationCacheProvider { cacheMap[forKey] = animation lruList.append(forKey) if lruList.count > cacheSize { - lruList.remove(at: 0) + let removed = lruList.remove(at: 0) + if removed != forKey { + cacheMap[removed] = nil + } } }