Error when calling ClearCache
Am getting a crash occurring when calling:
FFImageLoading.Forms.CachedImage.ClearCache(FFImageLoading.Cache.CacheType.All);
This runs on the main thread after we dispose some pages (have tested it running before other pages are disposed as well just to be sure we aren't modifying the image cache at all).
Crash trace that occurs after a bunch of evictions:
An action scheduled for the main thread threw an exception: System.InvalidOperationException: Collection was modified after the enumerator was instantiated.
at System.Collections.Generic.LinkedList`1+Enumerator[T].MoveNext () [0x00016] in /Users/builder/data/lanes/2512/d3008455/source/mono/external/referencesource/System/compmod/system/collections/generic/linkedlist.cs:519
at FFImageLoading.Cache.ReuseBitmapDrawableCache.Clear () [0x000a8] in <filename unknown>:0
at FFImageLoading.Cache.ImageCache.Clear () [0x00000] in <filename unknown>:0
at FFImageLoading.ImageService.InvalidateMemoryCache () [0x00018] in <filename unknown>:0
at FFImageLoading.Forms.Droid.CachedImageRenderer.ClearCache (CacheType cacheType) [0x0002d] in <filename unknown>:0
at FFImageLoading.Forms.CachedImage.ClearCache (CacheType cacheType) [0x00007] in <filename unknown>:0
at PROJECT.App.<.ctor>b__43 () [0x0005a] in App.cs:384
I'm pretty sure this was fixed a few days ago. Which version do you use?
2.0.3 currently.
Really weird I was sure it was fixed by https://github.com/molinch/FFImageLoading/commit/874b57e9f2395f34369285062e7c16bec52c9f7b
Which is part of 2.0.3
I'll double check in the morning, I may have only updated to 2.0.3 in another branch.
@molinch We could modify current implementation to use ConcurrentDictionary.
As said in the commit message I don't think it's needed: all calls to the dictionaries are surrounded by locks. Furthermore the only cases where I found an issue, which wasn't a threading issue, are now having a .ToList()
As I said earlier, I don't think that @ahohns issue is still present in 2.0.3
@molinch Ok then :)
Yep my apologies, I was testing it on 2.0.2 10 minutes before merging in the 2.0.3 update. Works fine on 2.0.3 thanks.
Thanks for the feedback!