react-native
react-native copied to clipboard
[Performance] Images on the iOS disk should be loaded from the background thread
Description
If an image is on the disk, we can't load it in the main thread, because it will cause the main thread to get stuck. The affected libraries include react-native-code-push and a series of libraries that save the image in the sandbox
https://github.com/facebook/react-native/blob/c868d5b26c5d680603d3f653de9277124c1b539b/Libraries/Image/RCTLocalAssetImageLoader.mm#L25-L35
After
- (BOOL)canLoadImageURL:(NSURL *)requestURL
{
- return RCTIsLocalAssetURL(requestURL);
+ return RCTIsBundleAssetURL(requestURL);
}
Why
The requiresScheduling returns false, so this is loaded in the main thread, but images on disk should be ignored here, then RCTImageURLLoaderRequest will automatically load it in a background thread
Version
all version
Output of npx react-native info
None
Steps to reproduce
None
Snack, code example, screenshot, or link to a repository
None