Cllocationmanager stopupdatinglocation not working

09-Nov-2019 20:04

Then dispatch work back onto the CLLocation Manager's home runloop in order to interact with it, rather than interacting with it or holding its lock from the background context.Other approaches may also work, but come with the observed risk of blockage. Engineering has determined that this issue behaves as intended. If you just have questions about the resolution, then please update your bug report with that information so we can respond.3) On the main thread call [location Manager stop Updating Location].Probably, some of the other methods would work as well, it's just the only method I tried. My concern is that it's not obvious and it's not documented anywhere, so someone might run into a similar situation (took me 4 days to understand where the problem is coming from).Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Now that Flip 2.0 is out and I have a bit of spare time on my hands, I thought it might be a good time to write about some of the things I learnt about Apple’s location services (which Flip uses extensively).So just a bit of background, Flip is an app I’ve been working on in my spare time for the last year, and is essentially a mobile messaging app with a location sharing component.So if you’re chatting with a group of friends, Flip has a feature where it can broadcast your location to your friends in real time, even when the app is not running in the foreground.

Best practice is to avoid doing this, and a-synchronize the bulk of your background work from accessing the CLLocation Manager.Here is an example project demonstrating the issue: https://github.com/DMAPro/Location Manager Deadlock (also attached to this report) Expected Results: The main thread and the background thread work independently Observed Results: The main thread (and the UI) freezes, until the background thread completes the task Version: Tested on i OS 8 / 9 / 10 (including the latest public release 10.3.2 14F89) on i Phone (both device & simulator). I completely understand the need for synchronization inside the CLLocation Manager.I've got two suggestions: 1) Add an internal (private) NSObject property inside the CLLocation Manager to use specifically for locking.Something like @property (nonatomic, strong) NSObject *locker; [email protected](self.locker) instead of @syncronized(self) This way the internal code would still be synchronized, but it would be safe to use the CLLocation Manager instance itself for synchronization elsewhere. CLLocation Manager is runloop-backed, captures the runloop on which it is initialized, and is ideally used only from that runloop subsequently. Other interaction with CLLocation Manager can be safely pursued from other threads/runloops/dispatch_queues (subject to the deallocation guarantee which is hard to make in practice if access is permitted from other threading contexts), but as you've discovered this is implemented through an internal @synchronized(self) lock.

Best practice is to avoid doing this, and a-synchronize the bulk of your background work from accessing the CLLocation Manager.Here is an example project demonstrating the issue: https://github.com/DMAPro/Location Manager Deadlock (also attached to this report) Expected Results: The main thread and the background thread work independently Observed Results: The main thread (and the UI) freezes, until the background thread completes the task Version: Tested on i OS 8 / 9 / 10 (including the latest public release 10.3.2 14F89) on i Phone (both device & simulator). I completely understand the need for synchronization inside the CLLocation Manager.I've got two suggestions: 1) Add an internal (private) NSObject property inside the CLLocation Manager to use specifically for locking.Something like @property (nonatomic, strong) NSObject *locker; [email protected](self.locker) instead of @syncronized(self) This way the internal code would still be synchronized, but it would be safe to use the CLLocation Manager instance itself for synchronization elsewhere. CLLocation Manager is runloop-backed, captures the runloop on which it is initialized, and is ideally used only from that runloop subsequently. Other interaction with CLLocation Manager can be safely pursued from other threads/runloops/dispatch_queues (subject to the deallocation guarantee which is hard to make in practice if access is permitted from other threading contexts), but as you've discovered this is implemented through an internal @synchronized(self) lock.Please note: Reports posted here will not necessarily be seen by Apple.