Skip to content
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

Merged
merged 6 commits into from
Nov 7, 2019

Conversation

darrengyles
Copy link
Contributor

Best as I can tell, a source type of ASNetworkImageSourceAsynchronousCache was meant to indicate a disk cache hit and ASNetworkImageSourceSynchronousCache was meant to indicate a memory cache hit. This change adds reporting of memory cache hits to the async rendering path.

Copy link
Member

@jparise jparise left a 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.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[_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) {

Copy link
Member

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?

Copy link
Contributor Author

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.

Source/ASNetworkImageNode.mm Outdated Show resolved Hide resolved
Source/Details/ASPINRemoteImageDownloader.mm Outdated Show resolved Hide resolved
@jparise jparise merged commit 744bb3e into TextureGroup:master Nov 7, 2019
Copy link
Member

@garrettmoon garrettmoon left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants