Gif image show high quality and flashes when scrolling RecyclerView as video shows
Fresco: 0.9.0
Issue: Gif image show high quality and flashes when scrolling RecyclerView as video shows. Seems Gif images doesn't resize and cache.
Log:
D/Charles.Lin: file:///storage/emulated/0/Download/test_image_a.jpg inMemoryCache:true
D/Charles.Lin: file:///storage/emulated/0/DCIM/Gif/tumblr_n8d80y1BDV1rk9vano1_500.gif inMemoryCache:false
D/Charles.Lin: file:///storage/emulated/0/DCIM/Gif/tumblr_n2nj3tO0Oh1qjk2rvo1_500.gif inMemoryCache:false
D/Charles.Lin: file:///storage/emulated/0/DCIM/Gif/florian-1.gif inMemoryCache:false
D/Charles.Lin: file:///storage/emulated/0/DCIM/Gif/DfQqM.gif inMemoryCache:false
D/Charles.Lin: file:///storage/emulated/0/DCIM/Tango/IMG_20160105_165156_0_.jpg inMemoryCache:true
D/Charles.Lin: file:///storage/emulated/0/DCIM/Tango/IMG_20160105_163839_0_.jpg inMemoryCache:true
D/Charles.Lin: file:///storage/emulated/0/DCIM/Tango/IMG_20160105_112223_0_.jpg inMemoryCache:true
Code in bindView:
Uri imageUri = Uri.fromFile(new File(galleryImage.getPath()));
boolean inMemoryCache = Fresco.getImagePipeline().isInBitmapMemoryCache(imageUri);
Log.d("Charles.Lin", imageUri + " inMemoryCache:" + inMemoryCache);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(imageUri)
.setResizeOptions(new ResizeOptions(100, 100))
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(mSimpleDraweeView.getController())
.setImageRequest(request)
.setAutoPlayAnimations(false)
.build();
mSimpleDraweeView.setController(controller);
.png can not resize
It is gif not png. And from log, those gif files are not in memory cache.
I have also faced with similiar problem. Check this out right here http://stackoverflow.com/questions/35014663/caching-gifs-in-fresco I have noticed - gifs are cached but simple
Fresco.getImagePipeline().isInBitmapMemoryCache(imageUri);
will not work. I checked it in that way.
public static boolean isImageDownloaded(Uri loadUri) {
if (loadUri == null) {
return false;
}
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance()
.getEncodedCacheKey(ImageRequest.fromUri(loadUri));
return ImagePipelineFactory.getInstance().getMainDiskStorageCache().hasKey(cacheKey)
|| ImagePipelineFactory.getInstance().getSmallImageDiskStorageCache()
.hasKey(cacheKey);
}
Yes, this is a known limitation. Animated images would be too big to have all frames decoded in memory at once so they don't get cached in the same way as static images. They are decoded on demand, and only a couple of frames (those about to be displayed) get cached. As explained in the documentation, resizing at the moment only works for JPEG images.
@plamenko - is it possible to configure fresco to display the first frame as soon as it is available so that the time to getting something on the screen is quicker? It seems to wait until it can animate smoothly.
@plamenko - it's worth mentioning also that this is an issue with react-native when using removeClippedSubviews on a ListView.
We've released Fresco v1.4.0, which includes a new implementation for animated GIFs that is way more performant, especially in the case where you display multiple GIFs. Let us know if you're still experiencing problems with 1.4.0.