onevcat / Kingfisher

A lightweight, pure-Swift library for downloading and caching images from the web.
MIT License
23.4k stars 2.66k forks source link

Can not load gif image from url with backgroundDecode. #2145

Open marcobui92 opened 1 year ago

marcobui92 commented 1 year ago

I can not load gif image from url when using backgroundDecode. It's just displayed with static image, not animated image. If i removed option backgroundDecode, it's oke but make a lagging for many gif images on the screen. How can i fix it? Thanks in advance.

FaisalShabbir007 commented 7 months ago

If you're experiencing issues with loading animated GIF images from URLs when using the backgroundDecode option in Kingfisher, there are a few potential solutions you can try:

Increase Memory Limit: The backgroundDecode option allows images to be decoded in the background, which can improve performance but may consume more memory. If you're experiencing issues with animated GIFs not loading properly, try increasing the memory limit for Kingfisher by setting the cacheMemoryCost property of the ImageCache.default instance to a higher value. This can help ensure that enough memory is available for decoding animated GIFs.

ImageCache.default.memoryStorage.config.totalCostLimit = 100 1024 1024 // 100 MB

Limit Concurrent Downloads: Kingfisher allows you to limit the number of concurrent image downloads using the maximumConcurrentDownloads property of the ImageDownloader.default instance. By reducing the number of concurrent downloads, you can prevent excessive memory usage and improve performance, especially when loading multiple GIF images simultaneously.

ImageDownloader.default.maxConcurrentDownloads = 4 // Limit to 4 concurrent downloads

Check Image Formats as well

nyb112 commented 7 months ago

@FaisalShabbir007 Not working