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

[iOS]: Crash on adding photo from camera if “Access to photos” permission not granted #3813

Closed
chrisbobbe opened this issue Jan 16, 2020 · 7 comments · Fixed by #3818
Closed
Assignees
Labels
a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS P1 high-priority severe: crash The app quits, or stops responding.

Comments

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Jan 16, 2020

I’ll fill this in with more detail tomorrow, but on iOS it seems that we have a crash when trying to add photos from the camera (not the media library!) when read access to photos (i.e., the media library) is not granted. Seen on iPhone 6s with iOS 13.3 on v26.20.143.

@chrisbobbe chrisbobbe added a-iOS severe: crash The app quits, or stops responding. a-compose/send Compose box, autocomplete, camera/upload, outbox, sending P1 high-priority labels Jan 16, 2020
@rheo-chiti
Copy link

rheo-chiti commented Jan 16, 2020

When access is not granted,an alert should be shown asking for permissions.
Can I work on this issue?

@chrisbobbe
Copy link
Contributor Author

Sure, thank you! There’s one thing I hadn’t pointed out in my initial comment (and I’ll write up something more tomorrow; I’m currently typing on mobile, so not as quickly, and should sleep soon as it’s 1:30 in the morning).

The native alert requesting permissions did actually display correctly, following the iOS quirk I mention in #3814, but the crash happened anyway. The crash also happens when you decline that permission, start up the app, and try again, when the native alert does not show up (again, following that quirk).

@rheo-chiti
Copy link

rheo-chiti commented Jan 16, 2020

On android, I cleared my data and didn't gave permissions to access photos but app didn't crashed .
On second time when I tried to add photo,nothing happened and it didn't asked for permissions.
The ideal thing would be to move the users to settings for permissions.

@rheo-chiti
Copy link

I fixed it for android ,when permissions are not granted initially,permissions can be granted later on.Like this->
20200116_224615

@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Jan 16, 2020

Ok! 🙂 I believe the issue you’re addressing is slightly different (maybe related to #3787?); this issue describes a complete crash of the app process on iOS, forcing a user to reopen the app, and it seems like that’s not happening on Android.

@chrisbobbe
Copy link
Contributor Author

I'll do some digging and see if I can come up with a fix for this today.

@chrisbobbe chrisbobbe self-assigned this Jan 16, 2020
chrisbobbe pushed a commit to chrisbobbe/zulip-mobile that referenced this issue Jan 16, 2020
Fixes zulip#3813.

On iOS, it appears that the fileName is not included in the response given
by ImagePicker.launchCamera if the user has not granted read access to their
photo library. The case where fileName is undefined was handled correctly,
but it turns out it's coming through as null, which was not handled. Neither
the types nor the docs from react-native-image-picker are clear on this point,
so that was filed as
react-native-image-picker/react-native-image-picker#1271.

I did not create a local copy of react-native-image-picker with the correct type,
since it's very likely that we'll need to upgrade to later versions frequently as
we're on an early version of this library which is known to have limitations
and bugs.

I added tests for fileName being undefined and being null.
@chrisbobbe
Copy link
Contributor Author

Just made a PR -- looks like fileName is not available when this permission is not granted, and instead of coming through as undefined, which is handled, it's null. The PR lets it handle null.

chrisbobbe pushed a commit to chrisbobbe/zulip-mobile that referenced this issue Jan 21, 2020
Fixes zulip#3813.

On iOS, it appears that the fileName is not included in the response given
by ImagePicker.launchCamera if the user has not granted read access to their
photo library. The case where fileName is undefined was handled correctly,
but it turns out it's coming through as null, which was not handled. Neither
the types nor the docs from react-native-image-picker are clear on this point,
so that was filed as
react-native-image-picker/react-native-image-picker#1271.

I did not create a local copy of react-native-image-picker with the correct type,
since it's very likely that we'll need to upgrade to later versions frequently as
we're on an early version of this library which is known to have limitations
and bugs. But this can be done, if preferred.

I added tests for fileName being undefined and being null.
chrisbobbe pushed a commit to chrisbobbe/zulip-mobile that referenced this issue Jan 30, 2020
Fixes: zulip#3813.

On iOS, it appears that the fileName is not included in the response
given by ImagePicker.launchCamera if the user has not granted read
access to their photo library. The case where fileName is undefined
was handled correctly, but it turns out it's coming through as null,
which was not handled, so, handle null.

Neither the types nor the docs from react-native-image-picker are
clear on this point, so that was filed as
react-native-image-picker/react-native-image-picker#1271.

Do this without creating a local copy of react-native-image-picker
with our own, correct type, since it's very likely that we'll need
to upgrade to later versions frequently as we're on an early version
of this library which is known to have limitations and bugs.

Add tests for fileName being undefined and being null.
rk-for-zulip pushed a commit that referenced this issue Jan 31, 2020
Fixes: #3813.

On iOS, it appears that the fileName is not included in the response
given by ImagePicker.launchCamera if the user has not granted read
access to their photo library. The case where fileName is undefined
was handled correctly, but it turns out it's coming through as null,
which was not handled, so, handle null.

Neither the types nor the docs from react-native-image-picker are
clear on this point, so that was filed as
react-native-image-picker/react-native-image-picker#1271.

Do this without creating a local copy of react-native-image-picker
with our own, correct type, since it's very likely that we'll need
to upgrade to later versions frequently as we're on an early version
of this library which is known to have limitations and bugs.

Add tests for fileName being undefined and being null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS P1 high-priority severe: crash The app quits, or stops responding.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants