Fix redundant requests for the same url during decoding time#3572
Fix redundant requests for the same url during decoding time#3572dreampiggy merged 3 commits intoSDWebImage:masterfrom
Conversation
|
Your changes seems break the Why that Because, some rare case, when during So, that So this Lock is here to ensure that behavior. However, seems your changes does not gurantee this behavior ever. Because Downloader no longer notice |
|
Another issue why I use an associated object, because you forget one feature, Custom Download Operation Class🤮 Not all users use This ugly design is used to support some advanced user who Don't use URLSession at all, they write their network stack from scratch like UNIX TCP, like FaceBook or ByteDance, but this can be done via custom |
|
Oh, after I read the code agin, seems you use the recursive check ? Check whether there are new handlers (re-using the same Download Operation) during decoding ? Is there still any possible chance (in theory) can cause some handler |
|
Unfortunately I really didn't give enough thought to why you would want to use an associated object rather than a property😭. |
|
When I used version 5.14.3 in my project again, I caught a rare case where some Views did not receive the |
If there is a newly added token before checkDone starts executing and Done executes, it may not be possible to respond to this newly added token. |
| @synchronized (self) { | ||
| tokens = [self.callbackTokens mutableCopy]; | ||
| } | ||
| [finisdTokens enumerateObjectsUsingBlock:^(SDWebImageDownloaderOperationToken * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { |
|
Can we use This checkDone does not take much CPU time, because just NSArray compare with pointer (That Others logic seems reasonable for me |
I envisioned a rare case. |
That why my It's a atomic operation need two classes to operate. Which means, Downloader lock the operation. Use Just do so. In SDWebImage v6.0.0,, this ugly design and Download operation class will be removed. |
No, the So, any logic in downloader (check whether to re-use or create new downloader operation) must execute after the |
…ows something that add new handlers during checkDone
Oh, I made a mistake. |
If you have a fork use another lock not Just the same, these two classes Need the same lock, no matter whatever type lock is. Back to this PR, I think it's just OK to mark the whole PS: This bug (missing callback handler) exists on Kingfisher as well, because it don't use lock, but no body cares.. (only me get some blames...) |
|
I have tried to run the modified code in my local demo and in another project and it seems to work. I'd appreciate it if you could review it for me when you have time☕️. |
|
LGTM |



New Pull Request Checklist
I have read and understood the CONTRIBUTING guide
I have read the Documentation
I have searched for a similar pull request in the project and found none
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
I have added the required tests to prove the fix/feature I am adding
I have updated the documentation (if necessary)
I have run the tests and they pass
I have run the lint and it passes (
pod lib lint)This merge request fixes / refers to the following issues: ...
Pull Request Description
fix redundant url requests #3571
After SDWebImageDownloaderOperation finishes downloading and processing all the current tokens, check if there are any new tokens added during the previous processing. If there are, continue to perform decoding tasks for the newly added tokens until all tasks are completed, then execute [self done].