candlefinance / faster-image

Fast image loading for React Native backed by performant native libraries.
https://candle.fi/discord
MIT License
479 stars 21 forks source link

Cache not used on Android #30

Open flodlc opened 1 month ago

flodlc commented 1 month ago

On version 1.5.0, the cache is used on IOS but on the same app on Android it does not work. I was surprised to see that with the basic RN Image component the cache seems to work on Android but not on IOS. I tried with differents cache policies with same results.

gtokman commented 1 month ago

@flodlc

  1. How did you determine that the cache was not working?
  2. Did you use a proxy and observe the network request go out on Android every time you loaded an image?
tconns commented 1 month ago

@flodlc I've checked and found that caching on Android still works with the 'cachePolicy: 'discWithCacheControl'' configuration. Are you using the 'cachePolicy: 'memory'' configuration?

mabdurrafey-afl commented 1 month ago

@gtokman On ios, I face the cache issue. Sometimes cached, sometime not. The images are loaded but when I navigate and same image is there aswell, it needs to load again

Home Page <FasterImageView source={ { url:${TMDB_API_HEAD}${imageUrl}, resizeMode: "cover", showActivityIndicator: true, progressiveLoadingEnabled: true, failureImage: blurhash, base64Placeholder: blurhash, cachePolicy: "discWithCacheControl" } } style={ { height: HEADER_MAX_HEIGHT, width: windowWidth, }} />

Inner Page <FasterImageView source={ { url:${TMDB_API_HEAD}${backdropUrl}, resizeMode: "cover", showActivityIndicator: true, progressiveLoadingEnabled: true, failureImage: blurhash, base64Placeholder: blurhash, cachePolicy: "discWithCacheControl", } } style={ { height: "100%", width: "100%", }} />

jamesholcomb commented 1 month ago

I believe I'm seeing this as well. here's a graph of our mapbox api static map usage

image

the spike on Apr-9 coincides with the release of the first version of the app that uses faster-image.

but not sure if it's iOS or Android (both versions hit the stores on the same day).

gtokman commented 1 month ago

@mabdurrafey-afl @jamesholcomb, thanks for the report. I've observed similar behavior interestingly and will take a look shortly.

@mabdurrafey-afl Your JS thread is getting smoked. Do you see the same behavior when commenting out the image or using the RN one?

gtokman commented 1 month ago

Updated to the latest version of Nuke on 1.6.