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

Crash when denying run-time permission for location access in NearbyActivity #861

Closed
Bluesir9 opened this issue Sep 3, 2017 · 17 comments
Closed
Assignees

Comments

@Bluesir9
Copy link
Contributor

Bluesir9 commented Sep 3, 2017

I am encountering the following crash when I deny the run-time permission for location access when I hit the NearbyActivity

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {fr.free.nrw.commons/fr.free.nrw.commons.nearby.NearbyActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.ActivityThread.deliverResults(ActivityThread.java:3699) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:650) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609) at fr.free.nrw.commons.nearby.NearbyActivity.onRequestPermissionsResult(NearbyActivity.java:167) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6553) at android.app.Activity.dispatchActivityResult(Activity.java:6432) at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)  at android.app.ActivityThread.-wrap16(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

This is cause the app is trying to load the NoPermissionsFragment in the onRequestPermissionsResult, which I think should be fine but clearly its not cause it crashes every time.

Secondly, launching a Fragment just to show a simple error message seems way too excessive. Personally, I would just show a dialog with the necessary error message along with 2 buttons, 1 with an "OK" text, clicking which would just close the activity and the other with a "Retry" text that would ask the run time permission again.

What do you guys think?

@misaochan
Copy link
Member

@Bluesir9 Interesting, it crashes for you EVERY time? Just to be clear, which version are you testing - the production release, the beta release, or the current master branch?

Yeah, I was undecided on creating a whole new Fragment just for the error message, but the suggestions at #707 swayed me. :) I would personally not mind the use of a dialog instead. What do the others think?

@Bluesir9
Copy link
Contributor Author

Bluesir9 commented Sep 4, 2017

@misaochan So actually the crash was obtained initially when I built from an outdated master. So I pulled fresh changes and built it and tried it again. And the crash persists and happens every time I hit the deny button on the run-time permission dialog.

Replacing the fragment with a dialog would be simple enough but yeah lets hear from the others as well.

@misaochan
Copy link
Member

@Bluesir9 If you don't mind, could you please try installing the version on Google Play and see if it crashes for you as well? If it doesn't, then we know that the problem lies with one of the pre-release changes.

Thanks!

@Bluesir9
Copy link
Contributor Author

Bluesir9 commented Sep 4, 2017

just tried it on the play store version and it crashed there as well.

@misaochan
Copy link
Member

Ah, okay, thanks. We definitely need to bump this up priority-wise, then.

@Bluesir9
Copy link
Contributor Author

Bluesir9 commented Sep 4, 2017

Of course. If we are decided on the Dialog route as a fix, then I could take this up. Will be a quick one anyways.

@sivaraam
Copy link
Member

sivaraam commented Sep 5, 2017

So, @Bluesir9 IIRC you're taking this up (assuming that you could take that thumbs up symbol as an acknowledgement)?

@Bluesir9
Copy link
Contributor Author

Bluesir9 commented Sep 5, 2017

@sivaraam yes

@sivaraam
Copy link
Member

sivaraam commented Sep 5, 2017

@Bluesir9 I guess somebody should assign this task to you to avoid it being showing from the task that has no asignee.

@maskaravivek
Copy link
Member

NoPermissionsFragment seems to be unused in the current master. I simply see a progress bar without any crash if i hit cancel. This is the dialog box that i am referring to.

location_permissions

Can we close this issue if it no longer happens.

@misaochan
Copy link
Member

I think @Bluesir9 has fixed this? The PR should ideally link to the issue next time though. :)

@Bluesir9
Copy link
Contributor Author

Yeah this has been fixed and merged. PR in question -> #866

@misaochan
Copy link
Member

Thanks @Bluesir9 !

@TGar21
Copy link

TGar21 commented Jun 2, 2018

@Bluesir9 Is this fixed on current Google Play version? I am new here, I just downloaded the app and I run into this crash.
If this should be fixed, can I create a new issue?

Environment: HTC 10, Android Oreo, version 2.7.1 from GP
Log:
06-02 12:44:46.199 12044 12044 E AndroidRuntime: FATAL EXCEPTION: main 06-02 12:44:46.199 12044 12044 E AndroidRuntime: Process: fr.free.nrw.commons, PID: 12044 06-02 12:44:46.199 12044 12044 E AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {fr.free.nrw.commons/fr.free.nrw.commons.nearby.NearbyActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4581) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4631) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.-wrap19(Unknown Source:0) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.os.Looper.loop(Looper.java:180) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6944) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:835) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.location.LatLng.from(LatLng.java:45) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.location.LocationServiceManager.getLKL(LocationServiceManager.java:93) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.nearby.NearbyActivity.onRequestPermissionsResult(NearbyActivity.java:163) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7399) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.Activity.dispatchActivityResult(Activity.java:7250) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4577) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: ... 9 more

@nicolas-raoul
Copy link
Member

@TGar21 Yes please create a new issue, thanks for your feedback!

@TGar21
Copy link

TGar21 commented Jun 2, 2018

Created #1581 (but I realized now, that it is something else probably)

@Bluesir9
Copy link
Contributor Author

Bluesir9 commented Jun 3, 2018

@TGar21 The stacktraces of the 2 crashes look different. The crash you encountered is caused because of calling "getLatitude" on a null "Location" object. So yeah, creating a new issue was the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants