Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

RequestPermissionsAsync hanging possibly with XPC Connection Error #174

Open
cjsharp01 opened this issue Apr 9, 2020 · 3 comments
Open

Comments

@cjsharp01
Copy link

Bug Information

Version Number of Plugin: 3.0.0.12
Device Tested On: iPhone X v13.2.3
Simulator Tested On: iPhone 11 v13.2.2 & iPhone 7 v10.3.1
Version of VS: Visual Studio for Mac 8.5.2
Version of Xamarin: 16.5.000.528
Versions of other things you are using:
Xamarin.Forms: 4.4.0.991640

Steps to reproduce the Behavior

It only affects IOS, Android is working fine.
Ensure the Location permissions for this App are not granted.

Expected Behavior

The pop up (asking whether the user allows the app to use their location) appears, the user clicks on one of the options and the code continues to run.

Actual Behavior

The pop up (asking whether the user allows the app to use their location) appears, the user clicks on one of the options but the app hangs because the code is waiting on CrossPermissions.Current.RequestPermissionsAsync to finish (it never does). I do notice that I get a message in the output "XPC connection interrupted" which I assume is what is causing me issues.

I think it is similar to issue number #64 but none of the solutions helped.

Code snippet

if (permissionStatus != PermissionStatus.Granted) { if (enableAskForPermissionPopup) { Dictionary<Permission, PermissionStatus> results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location }); permissionStatus = results[Permission.Location]; } }
it is in an Async method and the top level is being called by:
Task moveMapTask = Task.Run(async ()=> await GetLocationAndMoveTheMapAsync(false)); moveMapTask.Wait();

Permissions in plist:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationUsageDescription

@JanusMael
Copy link

JanusMael commented Apr 14, 2020

Also seeing this on nuget package version 6.0.1. It had been working at one point in the nuget package 5.0.0-beta

after looking further, it seems the TaskCompletionSource never has a result set and the Task await waits forever; it is supposed to be set by 'locationManager.AuthorizationChanged' but that isn't firing

@cjsharp01
Copy link
Author

Hi @Januschan, I managed to get this working yesterday by removing the Task.Run() and the .Wait(). I know it isn't good practice to run a (non-awaited) awaitable in a synchronous method but I haven't yet figured out how to properly run asynchronous methods in the constructor yet. It works for me because I don't need to await the method that runs this plugin (it just runs in the background and finishes before the user gets to the map).
I was going to close this ticket as it is effectively working for me but you seem to be having a similar issue so should I keep it open?

@JanusMael
Copy link

I think this issue needs to remain open due to the deadlock. I ended up putting a several second timeout for the wait, so it returns but it does not always get the result it was after.

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

No branches or pull requests

2 participants