sdwebimage: is there a limit on how many setimageW

2019-06-21 13:33发布

问题:

i'm wondering if there is an upper limit on how many setImageWithUrl messages can be submitted at one time ?i'm trying to load 30 photos , 10 of them are downloaded successful but the others entered in the requestFailed when trying to debug the issue

any hints or clarification ? Thanks

回答1:

For those who would come here seeking the answer about maximum number of concurrent downloads in SDWebImage, I would like to add to the previous answer.

I would not recommend changing init of SDWebImageDownloader, as you might want to update the SDWebImage or, like me, adjust the number of concurrent downloads in different areas of your app.

//thumbnails.m
//Loading thumbnails. It is faster to load them concurrently
SDWebImageManager.sharedManager.imageDownloader.maxConcurrentDownloads = 10;
[yourImageView setImageWithURL:thumbURL];

//fullScreen.m
//Loading big images in full-screen view, 
SDWebImageManager *sharedManager = [SDWebImageManager sharedManager];
[sharedManager.imageDownloader setMaxConcurrentDownloads:1];
[sharedManager cancelAll]; //cancel all current queue 
[yourImageView setImageWithURL:URL];


回答2:

Though your problem was due to incorrect urls as you mentioned, I am answering this for others who come in looking for the answer:

One can set the maximum concurrent download count in the latest release of SDWebImage framework by setting the variable, downloadQueue.maxConcurrentOperationCount in the init of SDWebImageDownloader. this would limit the maximum number of concurrent downloads for the 'downloadwithURL' call in the application. The framework would put any additional operations in the queue and execute them as the currently executing download completes.



回答3:

I found a strange problem by setting this value. Based on the apple doc, this value should only effect the concurrent download image number, not the total download image number. However, if my case, if this value is set to be 2, I can only download 2 images, even I call the download function more than 2. This value seems to set the size of the downloadQueue size, rather than the currentOperation number. Anyone has the same problem??