HKWorkoutSession distance tracking using HKAnchoredObjectQuery will sometimes stop working

Originator:dogsonic22
Number:rdar://39621240 Date Originated:4/21/2017
Status:Open Resolved:
Product:watchOS + SDK Product Version:watchOS 4
Classification:Bug Reproducible:occasionally
 
I have a fitness tracking app for the Apple Watch that is used by runners. It uses an HKAnchoredObjectQuery to report distance as they run. I've have reports from at least 6 users distance tracking will stop working partway through the workout. The symptoms are always the same. Typically distance samples are reported every few seconds. What happens is that is that distance samples will stop being reported for a long period of time and then a single distance sample will arrive with all the accumulated distance. Then typically no further distance samples are reported.  

Here's an example. You can see distance samples being reported every few seconds, but then a period of 10 minutes elapses before the next distance sample is reported. Then no further samples are reported for the rest of the workout. 

{
    "endDate": "2018-04-21T09:53:15+01:00", 
    "quantity": 9.981867978582159, 
    "startDate": "2018-04-21T09:53:12+01:00"
  }, 
  {
    "endDate": "2018-04-21T09:53:17+01:00", 
    "quantity": 8.883641727734357, 
    "startDate": "2018-04-21T09:53:15+01:00"
  }, 
  {
    "endDate": "2018-04-21T09:53:20+01:00", 
    "quantity": 6.127249873476103, 
    "startDate": "2018-04-21T09:53:17+01:00"
  }, 
  {
    "endDate": "2018-04-21T10:03:18+01:00", 
    "quantity": 1945.8662778341677, 
    "startDate": "2018-04-21T09:53:20+01:00"
  }

This user was running with just a Series 2 watch (no iPhone). The app also tracks the workout route using core location the the workout route map also stops at the same point, indicating the location updates also stopped being reported.

Steps to Reproduce:
The app tracks distance the same way was the Apple SpeedySloth example. However, the problem only occurs occasionally.

Expected Results:
Distance samples should be reported every few seconds

Actual Results:
Distance sample are sometimes not reported for minutes, followed by no further samples.

Version/Build:
watchOS 4

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!