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

CameraRoll.getPhotos return just a few on iOS #20462

Closed
andresespinosapc opened this issue Jul 31, 2018 · 14 comments
Closed

CameraRoll.getPhotos return just a few on iOS #20462

andresespinosapc opened this issue Jul 31, 2018 · 14 comments
Labels
API: CameraRoll Bug Platform: iOS iOS applications. Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.

Comments

@andresespinosapc
Copy link

Environment

Environment:
OS: Linux 4.15
Node: 10.6.0
Yarn: 1.7.0
npm: 6.1.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz => 0.55.4

Description

The CameraRoll.getPhotos function only returns some photos on iOS, while it works perfectly on Android. For example, if I use the following parameters

{
  first: 100,
  assetType: 'All',
  groupTypes: 'All',
}

I only get 39 photos, while I have more than a thousand in my camera roll. I have also tried with multiple different parameters, but the result is the same (or fewer photos because of a filter).

Reproducible Demo

https://snack.expo.io/Hyw-kQa4X

  • I think it must be run on a physical iOS device, because it has to access the camera roll.
  • The demo prints the length of response.length, where response is the resolved value of CameraRoll.getPhotos with the parameters I mentioned earlier.
@react-native-bot react-native-bot added Platform: iOS iOS applications. Platform: Linux Building on Linux. labels Jul 31, 2018
@hramos
Copy link
Contributor

hramos commented Jul 31, 2018

I just ran your Snack example on an iPhone X running iOS 11.4, and it's showing that it got 100 photos back
img_8307d70beff2-1.

@hramos
Copy link
Contributor

hramos commented Jul 31, 2018

After tapping Load Images a few more times, it looks like it's successfully getting pages with 100 photos each.
img_af757782ce99-1

@andresespinosapc
Copy link
Author

andresespinosapc commented Jul 31, 2018

Weird. I'm running it on an iPhone SE on iOS 11.4.1. Here's what I get:

photo_2018-07-31_19-15-31
(It goes back to 0 because it resets after reaching the end)

@andresespinosapc
Copy link
Author

I've just asked a friend with the same iPhone model and iOS version as me, and he had no problems. It's really weird. Does someone have any idea why this could happen?

@radreamer
Copy link

I have the same issue, but the number of photos is equal to 17

img_1566

@vohoangankhanh
Copy link

I am having the same problems but on Android

@airlaser
Copy link

This may relate to CameraRoll's underlying use of deprecated ALAssetsLibrary instead of the new PHPhotoLibrary . For example, it has trouble detecting photos and videos which are in iCloud but not stored locally.

A test -

Run

let assets = PHAsset.fetchAssets(with: .image, options: nil)
print(assets.count)

in a bridged Swift method. See what count that gives.

@hramos
Copy link
Contributor

hramos commented Dec 13, 2018

It may be that migrating to PHPhotoLibrary solves the issue, but it looks like that theory has not been put to the test yet.

@airlaser do you want to open a new separate issue to track the migration from ALAssetsLibrary to PHPhotoLibrary?

@airlaser
Copy link

airlaser commented Dec 13, 2018

Unless people's environments are starkly different from mine the switch will fix it. My app uses PHPhotoLibrary's PHAsset.fetch to get the IDs using bridge Swift code, then string manipulation to turn them into ALAssetsLibrary style URIs.

Everything else in React (Image tag, upload libraries, custom image tags, etc) will work just fine with ALAssetsLibrary URIs even if CameraRoll couldn't find them to begin with. They will not work with PHAssets. Live photo/burst get treated as their key frame single image.

I think the harder part of switching CameraRoll over is that everything else in React has to follow suit. It will require switching CameraRoll to have an option for whether it gives PHAssets or ALAssets, even if the only difference ends up being some string manipulation of the URI format.

@hramos What is the process for getting something like that done? I've never worked on React Native itself before.

@bartolkaruza
Copy link

As part of lean core initiative CameraRoll has been moved to https://github.com/react-native-community/react-native-cameraroll
On react-native-community/discussions-and-proposals#104 both this issue and #21836 have been marked as 'done' by @JoshuaGross .
All the commits from master regarding CameraRoll have been merged into the community repo, so if this issue is resolved, feel free to close it. If it is still relevant, I think it's best to continue the discussion on a new issue at the new home for CameraRoll.

@scarlac
Copy link
Contributor

scarlac commented Mar 29, 2019

@bartolkaruza After upgrading to 0.59.1 I just discovered that CameraRoll no longer works. No errors, no warning. There are no mentions in change logs and no mentions of breaking changes planned or deprecations for CameraRoll. Am I correct in understanding that CameraRoll is no longer going to be maintained within the RN codebase and we should use the community version from v0.59 and forward?

@airlaser
Copy link

On top of that, it seems that Image still does not work with photos://uuid URIs given by PHAsset and on some models of phone assets-library://uuid URIs have stopped working.

@bartolkaruza
Copy link

@bartolkaruza After upgrading to 0.59.1 I just discovered that CameraRoll no longer works. No errors, no warning. There are no mentions in change logs and no mentions of breaking changes planned or deprecations for CameraRoll. Am I correct in understanding that CameraRoll is no longer going to be maintained within the RN codebase and we should use the community version from v0.59 and forward?

The deprecation is taking place from 0.60 forward. The issues you are facing are related to recent changes in RN core, but the fixes should be made to the RNC repo, as that is the 'official' CameraRoll going forward.

I see you have already picked up on that here react-native-cameraroll/react-native-cameraroll#18, so I'm just posting this for anyone coming through here from search.

@bartolkaruza
Copy link

On top of that, it seems that Image still does not work with photos://uuid URIs given by PHAsset and on some models of phone assets-library://uuid URIs have stopped working.

@airlaser Can you post these as separate issues please? No-one is tracking this closed issue.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 12, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: CameraRoll Bug Platform: iOS iOS applications. Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants