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

Have ASNetworkImageNode report whether images were cached or not #639

Merged
merged 3 commits into from
Oct 25, 2017

Conversation

Adlai-Holler
Copy link
Member

This should help consumers who are interested in tracking their image cache performance.

} else if (_delegateFlags.delegateDidLoadImage) {
ASDN::MutexUnlocker l(__instanceLock__);
[_delegate imageNode:self didLoadImage:result];
}
Copy link
Member Author

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.

Copy link
Member

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);
}
}
Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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.

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.

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
Copy link
Member

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];
}
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

@Adlai-Holler Adlai-Holler merged commit af99ff5 into master Oct 25, 2017
@Adlai-Holler Adlai-Holler deleted the AHImageCacheChange branch October 25, 2017 22:57
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…tureGroup#639)

* Have ASNetworkImageNode report whether images were cached or not.

* Update changelog

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

Successfully merging this pull request may close these issues.

None yet

2 participants