FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

UWP InvalidateCacheEntryAsync leaves MemoryCache in inconsistent state

Open craigwi opened this issue 4 years ago • 0 comments

🐛 Bug Report

Calling FFImageLoading.ImageService.Instance.InvalidateCacheEntryAsync(url, FFImageLoading.Cache.CacheType.All) and then later trying to show the same url results in an exception "The LinkedList node does not belong to current LinkedList."

Expected behavior

No exception.

It appears that the issue is in the implementation of Remove in LRUCache.cs:

    public void Remove(TKey key)
    {
        LinkedListNode<LRUCacheItem<TKey, TValue>> node;
        if (_cacheMap.TryGetValue(key, out node))
        {
            _lruList.Remove(node);
        }
    }

The call '_lruList.Remove(node)' should probably 'this.RemoveNode(node)'. The code as it stands removes the item from the lru list, but not the dictionary.

Version: 2.4.11.982

Platform:

  • [ ] :iphone: iOS
  • [ ] :robot: Android
  • [ ] :checkered_flag: WPF
  • [X ] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [ ] :monkey: Xamarin.Forms

craigwi avatar Aug 27 '21 18:08 craigwi