CMPedometer `startPedometerUpdatesFromDate:withHandler:` has negative `CMPedometerData.distance` value
Originator: | SirAnaxagoras | ||
Number: | rdar://FB7721292 | Date Originated: | Jun 1, 2020 at 11:39 AM |
Status: | Open | Resolved: | |
Product: | Core Motion API (watchOS) | Product Version: | |
Classification: | Reproducible: | Sometimes |
We are seeing negative distance values from `CMPedometer` object sent to the updated handler of `-[CMPedometer startPedometerUpdatesFromDate:withHandler:]`. This seems to start at a negative value and then work its way forward as the users accrues distance: ``` 2020-06-01 06:44:17.310 negative_pedometer_update error "{ "cumulative_distance": -1.4304558401927352 }" 2020-06-01 06:44:17.302 negative_pedometer_update error "{ "cumulative_distance": -3.0058954493142664 }" 2020-06-01 06:44:17.294 negative_pedometer_update error "{ "cumulative_distance": -4.581335058435798 }" 2020-06-01 06:44:17.286 negative_pedometer_update error "{ "cumulative_distance": -4.581335058435798 }" 2020-06-01 06:44:17.279 negative_pedometer_update error "{ "cumulative_distance": -4.581335058435798 }" 2020-06-01 06:44:17.272 negative_pedometer_update error "{ "cumulative_distance": -14.033972713630646 }" 2020-06-01 06:44:17.264 negative_pedometer_update error "{ "cumulative_distance": -14.033972713630646 }" 2020-06-01 06:44:17.257 negative_pedometer_update error "{ "cumulative_distance": -14.033972713630646 }" 2020-06-01 06:44:17.249 negative_pedometer_update error "{ "cumulative_distance": -14.033972713630646 }" 2020-06-01 06:44:17.240 negative_pedometer_update error "{ "cumulative_distance": -20.21515619382262 }" 2020-06-01 06:44:17.230 negative_pedometer_update error "{ "cumulative_distance": -31.243233458604664 }" 2020-06-01 06:44:17.220 negative_pedometer_update error "{ "cumulative_distance": -31.243233458604664 }" 2020-06-01 06:44:17.209 negative_pedometer_update error "{ "cumulative_distance": -31.243233458604664 }" ``` These are all from a single app user's session. The timestamps aren't super relevant as they're related to when these messages were transferred from watchOS to iOS. Extra events from a timeframe of `2020-05-28` to `2020-06-01` are included for reference. This illustrates the start from a negative value and work its way forward for multiple users. The system does something like this when the issue seems to occur: 1. User says they want to start a workout within our application. 2. `-[HKHealthStore startWorkoutSession:]` 3. `-[CLLocationManager startUpdatingLocation]` 4. `-[CMPedometer startPedometerUpdatesFromDate:[NSDate date] withHandler:...]` - Started from `+[NSDate date]`, this handler dispatches to another object that moves the distance update to the main queue and then we log it on the main queue. 5. `-[CMMotionManager startAccelerometerUpdatesToQueue:withHandler:]` Should we save the initial value from the `CMPedometer` update handler and then consider that our local `0` value? It seems like the API _should not_ return a negative value at any point especially for a series of values moving toward `0`.
Comments
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!