-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
Reply already submitted crash #513
Comments
@humazed thanks for the bug report. I kinda know where the error is coming from (and I can make it go away), but I cannot really reproduce it and according to the stack traces you send me this error should not happen in the first place. So I am wondering if you can help me figure out what is causing this issue so I can solve it in the correct manner. So to give you some details, here is what I think is happening (based on the stack trace information and the steps you describe): Step 1:
So far all is good. Step 2:
The crash happens because the App somehow enters the Java @Override
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode != PERMISSION_REQUEST_CODE || permissions.length == 0 || grantResults.length == 0) {
if (this.resultCallback != null) {
this.resultCallback.onResult(LocationPermission.denied);
}
return false;
}
....
} As you would guess sending back the permission status in this situation will trigger the exception you listed above, because information has already been send on the channel. This is strange because from the way I understand the steps you take this would be a fresh channel and really should be the first time information is send back on the channel. What is also strange is that the @Override
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode != PERMISSION_REQUEST_CODE) {
if (this.resultCallback != null) {
this.resultCallback.onResult(LocationPermission.denied);
}
return false;
}
if (permissions.length == 0 || grantResults.length == 0) {
return false;
}
....
} But I am afraid this will mask the real problem that is occurring. Can you help me finding the real problem by checking the following:
Your help would be greatly appreciated. |
Step 1: will send you a screen recording. |
recording of the bug device: |
Hi, The steps to reproduce mine is simply: Allow location, then allow file and my apps crashed Device:
|
Hi @humazed, thank you for providing the reproduction steps, I think I have figured out the real problem that is occurring. I believe the error is happening because the permissions are requested multiple times while the first call is still being handled, which triggers a warning on the Android activity "W/Activity(24060): Can request only one set of permissions at a time", and results in the import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Geolocator #396'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState
extends State<MyHomePage>
with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeDependencies() {
getCurrentPosition(forceAndroidLocationManager: true).then((position) => print('Start: $position'));
super.didChangeDependencies();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print(state);
getCurrentPosition(forceAndroidLocationManager: true).then((position) => print('Resume: $position'));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),// This trailing comma makes auto-formatting nicer for build methods.
);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
} The problem is that this only happens when you need to request for permissions. Remember that the
At the moment I am feeling the most for the first solution, since the others will have other disadvantages or are really introducing huge breaking changes. I will implement the first solution now to make sure we have a workable solution. But I am interested in how you would feel about the different options? |
Hi @humazed, @NindoK, I have just released version 6.0.0+4 of the geolocator plugin which should solve this issue using the 1st option I described in the comment above. Thanks to the information from @humazed I was able to reproduce the problem and confirm that this change should fix the issue. You might however still see the warning "W/Activity(24060): Can request only one set of permissions at a time" which you can ignore. Let me know if this will solve the issue for you, in the meantime I will keep this issue open. |
Thanks it fixed it! |
Hi @NindoK, thank you for testing and confirming the problem is fixed. Will close the issue now. |
I can also confirm it is fixed thank you
…On Tue, Sep 8, 2020 at 7:49 PM Maurits van Beusekom < ***@***.***> wrote:
Closed #513 <#513>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#513 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACDNYJVA5E6SXFCN6LAIUITSEZVBHANCNFSM4QZMGFKQ>
.
|
I am still experiencing this crash in |
Hi @xJon, could you maybe provide a stack trace or some logging that shows the problem that is occurring? Can you maybe provide some information on the other plugin you are using that you mentioned is clashing with the geolocator? We have seen similar issues with other plugins that don't handle the Android |
Hi @mvanbeusekom, yes this is my log:
I made sure I am using the latest version of the package. It is odd though, as I am unable to reproduce this issue continuously; I re-added now the code which seemed to cause the issue, and I don't experience the crash. |
There should be no need to disable the automatic permission resolution since the geolocator will first check if permissions have been granted / disabled before taking any action and request permission. Meaning if you already took care of handling permissions the geolocator would simply skip the permission resolution. Could it be that you were running an older version of the geolocator plugin and re-adding the code made sure you updated to the latest version of the geolocator? Maybe you ran the |
I could've swore I ran I don't fully understand what you mean with the automatic permission resolution, as currently if the user denies my first request when the app launches (using the |
@xJon What he means is that if a user has "always allowed" permissions or "denied (dont ask me again)" permission, the plugin will not make a request to Android to display the permissions dialog. The reason you user gets a request is probably because they allowed or denied their permission temporarily (or "just this once"). |
@ianendboss I see. Thank you for the explanation! |
🐛 Bug Report
In the sample app LastKnownLocationExampleWidget deny the permission close and reopen the app I get the following exception and the app crashes.
Version: 6.0.0+3
Platform:
The text was updated successfully, but these errors were encountered: