Skip to content

ImageView will cancel same pictures loading, if the previous picture has not been loaded yet. #3568

@BrunoMa0429

Description

@BrunoMa0429

New Issue Checklist

Issue Description and Steps

When you have a ImageView in your tableview cell.
1.The page landing API responds and set image url to the imageView, SD start( T0) to load the picture(100ms).
2. at T0 + 50 ms, some logic trigger tableView reload, the previous picture still in loading, and a same imageUrl was set to it, SD will cancel current operation and restart a new one to load this picture.
3. in Charles you can see below case
Screenshot 2023-07-24 at 4 28 59 PM
Screenshot 2023-07-24 at 4 30 38 PM
it is called by

- (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key {
    if (key) {
        // Cancel in progress downloader from queue
        SDOperationsDictionary *operationDictionary = [self sd_operationDictionary];
        id<SDWebImageOperation> operation;
        
        @synchronized (self) {
            operation = [operationDictionary objectForKey:key];
        }
        if (operation) {
            if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) {
                [operation cancel];
                printf(@"@#@ - cancel");
            }
            @synchronized (self) {
                [operationDictionary removeObjectForKey:key];
            }
        }
    }
}

I can understand it could be used for load different pictures, but for same pictures I think it is better to avoid duplicated loading, it will delay the customer see the image.

Please help correct me, if there is something I misunderstand, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignSomething behavior by design currentlydiscussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions