-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have ASNetworkImageNode report whether images were cached or not #639
Conversation
} else if (_delegateFlags.delegateDidLoadImage) { | ||
ASDN::MutexUnlocker l(__instanceLock__); | ||
[_delegate imageNode:self didLoadImage:result]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We previously weren't calling out to the delegate at all in this synchronous fetch scenario. I think we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
} else { | ||
dispatch_async(queue, work); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this method because I added another callback path and it felt silly to keep duplicating code. Sorry, dear reviewer!
// feedback to the consumer about whether images are cached, we can't simply make the cache a no-op and | ||
// check the cache as part of this download. | ||
return [[self sharedPINRemoteImageManager] downloadImageWithURLs:URLs | ||
options:PINRemoteImageManagerDownloadOptionsSkipDecode | PINRemoteImageManagerDownloadOptionsIgnoreCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I don't think we should skip the cache because the synchronous cache check only checks the memory cache not the disk cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we'll check the disk cache in cachedImageWithURL:callbackQueue:completion:
so I think we're OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take this back, didn't see that the cache check above was implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For history, @Adlai-Holler and I discussed and we think this is safe. He pointed out the only case where this could cause an extra download is:
- request0 -> cache: miss
- request0 -> download: started
- request1 -> cache: miss
- request0 -> download: finished
- request1 -> download: started
This seems very unlikely in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think this is better from a Texture perspective than our sorta hacky behavior previously.
// feedback to the consumer about whether images are cached, we can't simply make the cache a no-op and | ||
// check the cache as part of this download. | ||
return [[self sharedPINRemoteImageManager] downloadImageWithURLs:URLs | ||
options:PINRemoteImageManagerDownloadOptionsSkipDecode | PINRemoteImageManagerDownloadOptionsIgnoreCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For history, @Adlai-Holler and I discussed and we think this is safe. He pointed out the only case where this could cause an extra download is:
- request0 -> cache: miss
- request0 -> download: started
- request1 -> cache: miss
- request0 -> download: finished
- request1 -> download: started
This seems very unlikely in practice.
} else if (_delegateFlags.delegateDidLoadImage) { | ||
ASDN::MutexUnlocker l(__instanceLock__); | ||
[_delegate imageNode:self didLoadImage:result]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
…tureGroup#639) * Have ASNetworkImageNode report whether images were cached or not. * Update changelog * Add fileURL case
This should help consumers who are interested in tracking their image cache performance.