-
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
Fix for images retrieved from the memory cache being reported as disk cache hits. #1722
Conversation
…as disk (i.e. asynchronous) cache hits.
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.
One meta-comment: instead of a BOOL
, do you think we should introduced a more generic CacheType
enum type?
I can't think of a cache source other than memory or disk, but maybe we'd want to represent other types in the future.
Source/ASMultiplexImageNode.mm
Outdated
@@ -806,7 +806,7 @@ - (void)_fetchImageWithIdentifierFromCache:(id)imageIdentifier URL:(NSURL *)imag | |||
ASDisplayNodeAssertNotNil(completionBlock, @"completionBlock is required"); | |||
|
|||
if (_cache) { | |||
[_cache cachedImageWithURL:imageURL callbackQueue:dispatch_get_main_queue() completion:^(id <ASImageContainerProtocol> imageContainer) { | |||
[_cache cachedImageWithURL:imageURL callbackQueue:dispatch_get_main_queue() completion:^(id <ASImageContainerProtocol> imageContainer, BOOL isFromMemoryCache) { |
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.
[_cache cachedImageWithURL:imageURL callbackQueue:dispatch_get_main_queue() completion:^(id <ASImageContainerProtocol> imageContainer, BOOL isFromMemoryCache) { | |
[_cache cachedImageWithURL:imageURL callbackQueue:dispatch_get_main_queue() completion:^(id <ASImageContainerProtocol> imageContainer, __unused BOOL isFromMemoryCache) { |
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.
This actually wasn't the intention originally. The protocol is in place so any library can provide image downloading and caching either synchronously or asynchronously. It wasn't intended that Texture would know how the cache is backed. I'm guessing some coupling between PINRemoteImage and Texture has crept back in…
I would recommend reporting async / sync?
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.
@jparise Done
@garrettmoon Thanks for the context, have updated to use ansync/sync terminology.
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.
Thanks for addressing my comments, LGTM!
Best as I can tell, a source type of
ASNetworkImageSourceAsynchronousCache
was meant to indicate a disk cache hit andASNetworkImageSourceSynchronousCache
was meant to indicate a memory cache hit. This change adds reporting of memory cache hits to the async rendering path.