fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Gif image show high quality and flashes when scrolling RecyclerView as video shows

Open CharlesLin99 opened this issue 10 years ago • 7 comments

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. anglermmb29mtaishanlin01212016190153 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);

CharlesLin99 avatar Jan 25 '16 12:01 CharlesLin99

.png can not resize

my519820363 avatar Jan 26 '16 04:01 my519820363

It is gif not png. And from log, those gif files are not in memory cache.

CharlesLin99 avatar Jan 26 '16 05:01 CharlesLin99

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);
    }

Nihilus13 avatar Jan 27 '16 09:01 Nihilus13

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 avatar Jan 27 '16 16:01 plamenko

@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.

brentvatne avatar Feb 11 '16 08:02 brentvatne

@plamenko - it's worth mentioning also that this is an issue with react-native when using removeClippedSubviews on a ListView.

brentvatne avatar Feb 16 '16 23:02 brentvatne

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.

oprisnik avatar Jul 17 '17 14:07 oprisnik