georstat / react-native-image-cache

React-Native image caching in file system with progressive loading for iOS and Android
MIT License
372 stars 30 forks source link

Images occasionally fail to render after background #86

Open oddanderson opened 1 month ago

oddanderson commented 1 month ago

My config:

CacheManager.config = {
  baseDir: `${Dirs.CacheDir}/images_cache/`,
  blurRadius: 15,
  cacheLimit: 1024 * 1024 * 20,
  maxRetries: 3,
  retryDelay: 200,
  sourceAnimationDuration: 200,
  thumbnailAnimationDuration: 200,
};

Using Expo to install.

Happens on iOS, reproduceable only on a device, not simulator.

On app open, the images all load correctly in a FlatList. However, after backgrounding the app for ~2 minutes and re-opening, many of the images that had previously loaded will gone and will not return without force quitting.

oddanderson commented 1 month ago

I did identify what's happening.

If the cache limit is hit and images are pruned while in a Flatlist, there is nothing that will trigger re-fetching the images until the flatlist items are recycled, which doesn't seem to happen very often.