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

Essentials Location Permissions Set result after cleanup of iOS LocationManager #5795

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

jfversluis
Copy link
Member

Description of Change

Port of this change in Xamarin.Essentials: xamarin/Essentials#1815

On IOS if you like to request LocationAlways you have to request locationWhenInUse first. This means in an average implementation one would have 2 consecutive calls
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
await Permissions.RequestAsync<Permissions.LocationAlways>();
Both use the static LocationManager instance.
Since RequestAsync<Permissions.LocationWhenInUse>() sets the result of the task completition source before cleaning up its locationManager there is a race condition where RequestAsync<Permission.LocationAlways>() already runs and thus this cleanup disposes the locationManager used by the second call. This will not always be the case but in my test around 50% of the time. Workaround wait 3-10 seconds in between the calls

Issues Fixed

Original Xamarin.Essentials bug: xamarin/Essentials#1489

@jfversluis jfversluis added area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/iOS 🍎 labels Apr 4, 2022
@jfversluis jfversluis merged commit aabd719 into main Apr 4, 2022
@jfversluis jfversluis deleted the xe-1815-port branch April 4, 2022 17:55
@mattleibow mattleibow added this to the 6.0.300-rc.2 milestone Apr 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2023
@samhouts samhouts added the fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info fixed-in-6.0.300-rc.2 Look for this fix in 6.0.300-rc.2! platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants