SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.16k stars 223 forks source link

Memory issue when adding multiple images in a LazyGridView and updating the view during the upload #154

Closed nastasiupta closed 3 years ago

nastasiupta commented 3 years ago

I display a LazyGridView with the images the user uploaded before. Also, he has the option to add more images, and after he selects 10/20 images or more, I display to him a preview of the images while they are uploaded to the server. During the upload (for example 5 images at a time), I display the progress for each image and this causes reload of the view and during this, the memory spikes up to 700mb, even those 20 images have a total of 60mb. Also, the LazyGridView is inside a ScrollView, and if I want to scroll during the upload process the view stucks... the scroll is not smooth. I made this test with multiple images uploaded at a time. Even if I upload images one by one the scroll is not 100% smooth. I removed the displaying image part and display only the progress and the scroll is smooth.

I have used SDWebImage in UIKit apps before and everything was fine but I'm not sure what happens on SwiftUI... why the memory spikes so much? And considering that I use a lazy view, why the memory is not deallocating properly so I can see that the memory increased at a certain point but after that, it should be stable at a reasonable amount.