-
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
[Android] Tried to use permissions API while not attached to an Activity. #10009
Comments
Same problem on RN 0.35.0.RC.0. |
Well the stack trace looks pretty clear. Was your React instance manager attached to an activity when you called this or not? It's a plain English error message, I don't see what you are asking here. |
@hey99xx how could there be no activity? |
Seems like #10221 could fix the issue. Waiting for review. |
Summary: We're seeing a lot of crashes from `PermissionsModule` not being able to access the current activity, mentioned in #10009 and here: #9310 (comment) As far as I can tell, there is no way to ensure the Activity exists since the `ReactContext` holds a `WeakReference` to the current Activity and it appears that the lifecycle calls are happening in the right order (so not the same as #9310). This will at least allow people to catch the error in JS and update the UI or try again as opposed to crashing the app. I'm working on some bigger changes in #10221 but this is a smaller change and important to get fixed I think. Closes #10351 Differential Revision: D4010242 fbshipit-source-id: 7a76973bb2b3e45817d4283917740c89a10ec0b0
The problem is still here. I can reproduce it now. When my app loads for the first time, the permission dialog is shown. If user "pauses" app by clicking on right button on Android or if there is another app appears over my app (message from messenger, for example) and if after that app becomes "unpaused" (resumed), then it crashes at that moment. I can guess, the problem is somewhat connected with reactContext and with the way the app becomes resumed after onPause. |
Summary: We're seeing a lot of crashes from `PermissionsModule` not being able to access the current activity, mentioned in #10009 and here: #9310 (comment) As far as I can tell, there is no way to ensure the Activity exists since the `ReactContext` holds a `WeakReference` to the current Activity and it appears that the lifecycle calls are happening in the right order (so not the same as #9310). This will at least allow people to catch the error in JS and update the UI or try again as opposed to crashing the app. I'm working on some bigger changes in #10221 but this is a smaller change and important to get fixed I think. Closes #10351 Differential Revision: D4010242 fbshipit-source-id: 7a76973bb2b3e45817d4283917740c89a10ec0b0
…sions Summary: In order to get featured in the Google Play Store, we had to handle a few specific cases with permissions based on feedback from the editorial team. First, which was previously possible with this permissions module was bumping the sdk to version 23. The second is requesting multiple permissions at one time. In order for the camera + upload to work, we needed to request both camera permissions + media storage in one flow. The last is handling the case where the user checks the "Never Ask Again" box. This will only appear after a user denies a permission once and is then prompted again. The logic for handling this case is taken from here: http://stackoverflow.com/questions/31928868/how-do-we-distinguish-never-asked-from-stop-asking-in-android-ms-runtime-permis/35495372#35495372 We were also seeing a few crashes similar to #10009 due to `onRequestPermissionsResult` being called before `onResume` (http://stackoverflow.com/questions/35205643/why-is-onresume-called-after-onrequestpermissionsresult), so I delaye Closes #10221 Differential Revision: D4232551 fbshipit-source-id: fee698d1c48a2d86623cb87996f3d17f4c10a62e
…sions Summary: In order to get featured in the Google Play Store, we had to handle a few specific cases with permissions based on feedback from the editorial team. First, which was previously possible with this permissions module was bumping the sdk to version 23. The second is requesting multiple permissions at one time. In order for the camera + upload to work, we needed to request both camera permissions + media storage in one flow. The last is handling the case where the user checks the "Never Ask Again" box. This will only appear after a user denies a permission once and is then prompted again. The logic for handling this case is taken from here: http://stackoverflow.com/questions/31928868/how-do-we-distinguish-never-asked-from-stop-asking-in-android-ms-runtime-permis/35495372#35495372 We were also seeing a few crashes similar to facebook#10009 due to `onRequestPermissionsResult` being called before `onResume` (http://stackoverflow.com/questions/35205643/why-is-onresume-called-after-onrequestpermissionsresult), so I delaye Closes facebook#10221 Differential Revision: D4232551 fbshipit-source-id: fee698d1c48a2d86623cb87996f3d17f4c10a62e
I was having the same problem as I was requesting the permission as soon as the Activity was created. Delaying the permission request a bit solved it for me. |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
I see this on a real device with react-native 0.47. Didn't see it on an emulator. |
Still present on 0.47 |
I think this happens when the app is in the background while starting or requesting permissions and may only happen in dev mode. |
This happens to me while using react-native-navigation in release mode. It's probably related to RNN but I'm not sure. |
I got the same issue to @mannol The crash only happens after a fresh install of my app (delete my app and install it). It works well if I turn off the location permission of my app in settings and reopen my app. Here is my adb logcat result:
|
I'm having this issue as well, why is this issue closed? |
Same here |
Same here... |
Turned out it was problems with Oreo. Use the latest RN
…On 29 Nov 2017 8:26 a.m., "Antonio Moreno Valls" ***@***.***> wrote:
Same here...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10009 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJKw_RT3OUwIAJKFiX0CQP3abDJUld4Uks5s7RUogaJpZM4KCaR7>
.
|
@thevolcanomanishere using last RN version that supports Oreo and error stills there. Probably is something related to |
@Moreno97 Sorry I was thinking of a separate problem. It was RNN. I removed it and it went away. RNN with the react native debug overlay doesn't request permissions properly in line with Androids new permission model for drawing over the screen. |
@thevolcanomanishere so the problem is RNN. I suppose there's no fix for that, true? |
I read somewhere about implementing PermissionAwareActivity but just gave
up and reverted to my old navigation.
Regards,
Alex McGonagle
…On Wed, Nov 29, 2017 at 11:12 AM, Antonio Moreno Valls < ***@***.***> wrote:
@thevolcanomanishere <https://github.com/thevolcanomanishere> so the
problem is RNN. I suppose there's no fix for that, true?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10009 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJKw_fjIg5TJ2URO1qVEHForKKIzjylCks5s7TwJgaJpZM4KCaR7>
.
|
@thevolcanomanishere that was already implemented on previous versions in RNN. Probably a quick fix is using |
Anyone have a fix or workaround?
I'm requesting permissions after the screen is visible so I don't see why this happens. react-native 0.54 |
This may fix: wix/react-native-navigation#2043 (comment) |
@Moreno97 setTimeout worked for me but what a hack. I'm not using anything special in React-native-navigation so I should just dump it since it's giving me such pains... |
I've got this error.
I'm using RN Android Permission Module.
Tested on RN 0.33.0 and RN 0.34.0.RC.0.
Problem occurs only on Android devices with API Level 23+ (where Android Permission Module is used).
Here is my code:
And here is stack trace:
The text was updated successfully, but these errors were encountered: