react-native-fast-image: Won't display assets-library URIs on iOS

Using CameraRoll in react native gives a URI formatted as assets-library://asset/asset.... This used to work with this library. It still works with react’s Image tag. However, this library now shows a blank image instead. Not sure which build caused it as I’m having trouble rolling back.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 8
  • Comments: 24 (12 by maintainers)

Most upvoted comments

I’ve some researched about this issue and conclude it’s SDWebImage’s problem. because they does not support PHAsset which is can handle assets-library protocol.

Please check below comments. react-native-fast-image is currently using SDWebImage@4.2.2 and SDWebImage@5.x is still beta yet. (I found current version through Podfile.lock but not sure)

Maybe we can add PHAsset support in 5.x or by a seperate Pods commented on 25 Jan 2018 in SDWebImage repository

Release status of SDWebImage 5.0.0-beta3 was released on 30 Aug 2018.

However ReactNative’s Image is supporting assets-library. they have logic for assets-library not like SDWebImage@4.x’s local image handling logic which always returns nil about assets-library image.

I think this should be supported by implementing own assets-library handling or upgrading SDWebImage@5.x which is now supporting through SDWebImagePhotosPlugin.

@DylanVann Can you follow up this issue?

I can load images from cameraroll with FastImage but got memory issue when scrolling down to load more photos

Message from debugger: Terminated due to memory issue
  pod 'SDWebImage', '~> 5.0'
  pod 'SDWebImagePhotosPlugin', '~> 1.0'

@r0b0t3d Did you check something documentation of SDWebImagePhotosPlugin-Memory Warning ? Which allows some customization about image loading size.

For iPhone X+ devices, the Camera pixel size is higher than 4000x 4000, so it’s better to limit the size. You can change the default image pixel size using the APIs. For example like this:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Add multiple loaders with Photos Asset support
    [SDImageLoadersManager.sharedManager addLoader:SDWebImagePhotosLoader.sharedLoader];
    // Limit default query pixel size (only 1000x1000)
    SDWebImagePhotosLoader.sharedLoader.imageRequestOptions.sd_targetSize = CGSizeMake(1000, 1000); 
    SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;
    
    return YES;
}