Eric Samelson 2ca7701aae Performance improvement for loading cached images on iOS (#20356)
Summary:
This PR increases the speed at which cached images are loaded and displayed on the screen. Images are currently cached in memory using RCTImageCache, but each time they are loaded, a round trip through RCTNetworking happens before RCTImageCache is even checked. This is likely so that RCTNetworking can handle the caching behavior required by the HTTP headers. However, this means that at the very least, images are read from disk each time they're loaded.

This PR makes RCTImageLoader check RCTImageCache _before_ sending a request to RCTNetworking. RCTImageCache stores a bit of information about the response headers so that it can respect Cache-Control fields without needing a roundtrip through RCTNetworking.

Here are a couple of graphs showing improved loading times before this change (blue) and after (red) with SDWebImage (yellow) as a baseline comparison. The increase is most evident when loading especially large (hi-res photo size) images, or loading multiple images at a time.
https://imgur.com/a/cnL47Z0

More performance gains can potentially be had by increasing the size limit of RCTImageCache: 1a6666a116/Libraries/Image/RCTImageCache.m (L39) but this comes at the tradeoff of being more likely to run into OOM crashes.
Pull Request resolved: https://github.com/facebook/react-native/pull/20356

Reviewed By: shergin

Differential Revision: D8978844

Pulled By: hramos

fbshipit-source-id: 4b86043bc14c40007b0596c9f8a213455b697686
2018-07-30 14:17:13 -07:00
..
2018-05-10 19:10:38 -07:00
2018-05-10 19:10:38 -07:00
2018-07-19 19:02:13 -07:00
2018-06-06 05:32:06 -07:00
2018-05-10 19:10:38 -07:00
2018-06-19 23:48:12 -07:00
2018-06-19 23:48:12 -07:00
2018-05-10 19:10:38 -07:00
2018-05-10 19:10:38 -07:00
2018-06-19 23:48:12 -07:00
2018-03-08 12:10:14 -08:00
2018-05-10 19:10:38 -07:00