CLLocationManager hangs

Originator:ericcj
Number:rdar://16994205 Date Originated:5/21/2014
Status:Open Resolved:
Product:iOS SDK Product Version:7.1.1
Classification:Crash/Hang/Data Loss Reproducible:Sometimes
 
[CLLocationManager authorizationStatus] is often taking 1-30 seconds to return in our app.  This happens in about 1/2 of our app foregrounds in about 9/10 of our phones across 4s, 5, and 5s models but never in the simulator.  Our app uses significant location and region monitoring.  Other methods of CLLocationManager including monitoredRegions, location, and locationServicesEnabled sometimes have similar hangs, so it's possible that we just happen to see it in authorizationStatus most often since that's the first call.  We never see it happen on a fresh application launch, only when foregrounding the app after it's already been running.  Deleting and reinstalling our app has no effect.  Disabling wifi has no effect.  Enabling airplane mode fixes the problem entirely not just while it's enabled but for some time after we turn airplane mode back off.  

Occasionally I see locationd crashes like the log attached but I'm not sure those are related.  

On occasion we've had it start happening in other apps that use location such as google, twitter and foursquare, after which only a "reset all settings" will fix it, but that could be a different bug.

Steps to Reproduce:
1.  Install our app
2.  Hope your phone has the problem
3.  Launch the app
4.  Background the app
5.  Foreground the app and observe the hang

Expected Results:
We expect all these CLLocationManager methods to be safe to call synchronously, even on the main queue since it's fairly difficult to run on a background queue needing a run loop

Actual Results:
Hangs

Version:
ios 7.1.1

Notes:
Others having this problem:

https://devforums.apple.com/message/967592

https://devforums.apple.com/message/967581

http://stackoverflow.com/questions/20531496/unexpected-delay-lag-freezing-blocking-when-calling-cllocationmanager-authoriza

Configuration:
Iphone 4s, 5, and 5s using wifi


attaching another locationd crash from a different phone.  applications like Chrome, Secret, and ours fail to launch in time hung on CLLocationManager calls, but unlike the other crash this one is always a SIG_TRAP in locations about a minute after those apps fail to launch.


this appears to still be happening in iOS 8 beta 1 as per 17240270


I'm beginning to think that the locationd crash with SIGTRAP is a different bug than our primary problem, but since I saw it a few times today even when I wasn't running the app from Xcode and hadn't uploaded a console log for it yet, here's the crash and what the console looks like while hanging on [CLLocationManager location] for 20s:

Jun 16 18:32:10  TimelordEnterprise[2437] <Warning>: 18:32:10.571-0400 +[TLAppHelper timeBlock:named:] [Line 1243] timeblock starting locationManager location
Jun 16 18:32:10  wifid[40] <Notice>: WiFi:[424650730.582828]: 
Jun 16 18:32:10  wifid[40] <Notice>: Too frequent(2.374139 secs) rssi event from driver
Jun 16 18:32:10  wifid[40] <Notice>: 
Jun 16 18:32:13  wifid[40] <Notice>: WiFi:[424650733.198769]: 
Jun 16 18:32:13  wifid[40] <Notice>: Too frequent(2.615941 secs) rssi event from driver
Jun 16 18:32:13  wifid[40] <Notice>: 
Jun 16 18:32:15  wifid[40] <Notice>: WiFi:[424650735.592152]: 
Jun 16 18:32:15  wifid[40] <Notice>: Too frequent(2.393382 secs) rssi event from driver
Jun 16 18:32:15  wifid[40] <Notice>: 
Jun 16 18:32:25  wifid[40] <Notice>: WiFi:[424650745.409316]: 
Jun 16 18:32:25  wifid[40] <Notice>: Too frequent(4.812137 secs) rssi event from driver
Jun 16 18:32:25  wifid[40] <Notice>: 
Jun 16 18:32:25  wifid[40] <Notice>: WiFi:[424650745.628663]: 
Jun 16 18:32:25  wifid[40] <Notice>: Too frequent(0.219348 secs) rssi event from driver, ignoring
Jun 16 18:32:25  wifid[40] <Notice>: 
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLFenceManagerSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLWifiLocationProviderSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLLocationHarvesterSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLTilesManagerSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLNetworkLocationProviderSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Heartbeat underflow for: CLUnifiedCellLocationProviderSilo  Going to crash now!
Jun 16 18:32:31  locationd[2483] <Error>: Assert Failed, /SourceCache/CoreLocation/CoreLocation-1613.35/Daemon/Providers/Location/Cell/CLUnifiedCellLocationProvider.mm, 63
Jun 16 18:32:31  ReportCrash[2688] <Notice>: ReportCrash acting against PID 2483
Jun 16 18:32:31  ReportCrash[2688] <Notice>: Formulating crash report for process locationd[2483]
Jun 16 18:32:31  TimelordEnterprise[2437] <Notice>: 18:32:31.498-0400 +[TLAppHelper timeBlock:named:] [Line 1250] timeblock : 20.926532 on main thread (locationManager location)


it's worth noting that we ran nearly identical code on iOS 6 extensively without hitting this problem, or at least without  hitting the severe 10s+ hangs/crashes since we would have definitely noticed those.  this popped up sometime in iOS 7


After going on a road trip where neither my phone or my wife's phone (who also runs our app) were usable for navigation due to this bug, I re-confirmed that deleting our app does not fix the problem.  I deleted our app from my 5s yesterday morning, but locationd is still frequently crashing with SIGTRAP and any app that uses location hangs until it crashes.  I've attached a screenshot showing how frequent the crashes are, and zipped up the 6:02-6:06PM crash logs from last night.  Since it's happening even without our app, I had the idea to go read the general iPhone forums and suspect that a bunch of users could be talking about this bug:  

http://forums.appleinsider.com/t/166341/users-report-freezing-lagging-iphones-with-apples-ios-7-1-but-overall-crashes-are-down
https://discussions.apple.com/thread/5994050?tstart=0

Comments

this bug is still present in iOS 8.1


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!