Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

set result after cleanup of locationmanager #1489 #1815

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

SiNeumann
Copy link
Contributor

Description of Change

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

Bugs Fixed

Provide links to issues here. Ensure that a GitHub issue was created for your feature or bug fix before sending PR.

API Changes

None

Behavioral Changes

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Updated documentation (see walkthrough)

@opbld31

This comment was marked as off-topic.

@jamesmontemagno
Copy link
Collaborator

This looks fine to me.

@jamesmontemagno jamesmontemagno added the ready-to-merge Review completed, Ready for API review and merge label Feb 15, 2022
@jamesmontemagno jamesmontemagno added this to the 1.7.2 milestone Feb 15, 2022
On IOS if you like to request LocationAlways you have to request locationWhenInUse first. This means in an average implementation one would have to consecutive call
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();  
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
@jfversluis
Copy link
Member

LGTM Thanks for your contribution to our little project @SiNeumann !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready-to-merge Review completed, Ready for API review and merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants