-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[CameraRoll] Add assetThumbnail prop #1406
Conversation
any news ? |
@Iragne Your fix works beautifully for me! |
ping @nicklockwood |
@@ -188,6 +197,7 @@ var nativeOnlyProps = { | |||
defaultImageSrc: true, | |||
imageTag: true, | |||
contentMode: true, | |||
assetThumb:true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, shouldn't this be assetThumbnail
?
I see this below:
RCT_CUSTOM_VIEW_PROPERTY(assetThumbnail, NSString, RCTStaticImage)
Yes agree with you |
@Iragne - can you rebase this and squash it into one commit? It looks like it won't be a clean merge |
@Iragne no worries. What puzzles me is that your code actually worked even with that bug... |
ok @brentvatne |
@Iragne I was curious whether you'll still get OOM crashes with thumbs and checked my camera roll with more than 200 videos. It ran fine without any problems. I believe for the thumbnail case you do not have to use a serial queue. In other words you could use this version (tested on my iPhone 6): if( !thumb ) {
// ALAssetLibrary API is async and will be multi-threaded. Loading a few full
// resolution images at once will spike the memory up to store the image data,
// and might trigger memory warnings and/or OOM crashes.
// To improve this, process the loaded asset in a serial queue.
dispatch_async(RCTImageLoaderQueue(), ^{
// Also make sure the image is released immediately after it's used so it
// doesn't spike the memory up during the process.
@autoreleasepool {
UIImage *image = nil;
ALAssetRepresentation *representation = [asset defaultRepresentation];
ALAssetOrientation orientation = [representation orientation];
image = [UIImage imageWithCGImage:[representation fullResolutionImage] scale:1.0f orientation:(UIImageOrientation)orientation];
RCTDispatchCallbackOnMainQueue(callback, nil, image);
}
});
} else {
@autoreleasepool {
UIImage *image = nil;
ALAssetRepresentation *representation = [asset defaultRepresentation];
ALAssetOrientation orientation = [representation orientation];
image = [UIImage imageWithCGImage:[asset thumbnail] scale:1.0f orientation:(UIImageOrientation)orientation];
RCTDispatchCallbackOnMainQueue(callback, nil, image);
}
} @brentvatne Would you prefer to have that optimization as a separate PR? |
@bparadie - yeah let's move that over to a separate PR! thanks |
@Iragne no worries, it was just an experiment. The performance is pretty good even with the serial queue. @brentvatne suggested keeping the optimization separate. May I ask why you think it's not a good idea to use async thumb creation? |
@bparadie thanks if you have other point please let me know. |
Closing because of the new PR |
* Enbale lint for version 0.25 * Fix lint errors for version 0.25
Load Assets from Photo library and a memory warning is send.
Add a property in Image to force the display to use the [asset thumbnail] method
Related Issue #779