CLLocationManager.headingOrientation setter does not check if it's already set to the new value

Originator:jason
Number:rdar://34059173 Date Originated:24-Aug-2017 11:54 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:10.3.1
Classification:Other Bug Reproducible:Always
 
Summary:
Setting CLLocationManager.headingOrientation to its existing value will trigger all of the same behaviors (e.g., a new heading update in -[CLLocationManagerDelegate locationManager:didUpdateHeading:]) as if the value had changed. This negates CLLocationManager.headingFilter if a developer attempts to set CLLocationManager.headingOrientation rapidly.

Steps to Reproduce:
1. Enable heading updates in a location manager and configure its delegate.
2. Set CLLocationManager.headingFilter to a large value, e.g., 10°. (Optional, makes it more obvious that the filter is ignored.)
3. Set CLLocationManager.headingOrientation to its existing value rapidly — several times a second, perhaps.
4. Observe heading updates in -[CLLocationManagerDelegate locationManager:didUpdateHeading:].

See attached demo project.

Expected Results:
CLLocationManager.headingOrientation would ignore being set to its existing value. No new heading event would be sent to its delegate.

Actual Results:
CLLocationManager.headingOrientation’s setter accepts the existing value and triggers its update behaviors, such as sending a new heading update to its delegate.

While sending a heading update when CLLocationManager.headingOrientation actually changes is desirable, doing this when there is effectively no change is not. If CLLocationManager.headingOrientation is set rapidly, heading updates will be sent/received at that same frequency and CLLocationManager.headingFilter will effectively be ignored.

Version:
10.3.1

Notes:
Workaround: check that you’re not setting CLLocationManager.headingOrientation to its existing value before you set it.

In the wild: https://github.com/mapbox/mapbox-gl-native/pull/9845

Comments

Demo project: https://github.com/friedbunny/headingFilterBork


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!