CMSensorRecorder does not return data close to the requested end date

Originator:jasdeep.saini
Number:rdar://26501672 Date Originated:5-26-16
Status:Insufficient Info Resolved:
Product:Apple Watch Product Version:Watch OS
Classification:Other Bug Reproducible:Always
 
Summary:
The accelerometerDataFromDate:toDate: method of CMSensorRecorder does not return data all the way to date specified by the toDate parameter.

Steps to Reproduce:
1. Call the recordAccelerometerForDuration with a duration of 4 minutes.

2. Wait 4 minutes for data to be recorded.

3. Request the 1st minute of the recorded accelerometer data.  Only the first minute is requested to ensure that requested data is at least 3 minutes old.

4.  If no data is returned, retry step #3 until data is returned.

Expected Results:
The gap between the CMRecordedAccelerometerData object's startDate & the requested toDate is usually between 0-3 seconds.

Actual Results:
The gap between the last CMRecordedAccelerometerData object's startDate & the requested toDate will be closer to 0 than to 3 seconds.

Version:
OS 2.2 & 2.2.1

Configuration:
Watch OS 2.2
 iOS 9.3.1
XCode 7.3 

Watch OS 2.2.1
iOS 9.3.2
XCode 7.3.1

Comments

This was fixed in WatchOS3

By jasdeep.saini at March 28, 2017, 12:39 a.m. (reply...)

Additional Information

Also wanted to clarify how I am getting my time stamps. I have filed another radar about the CMRecordedAccelerometerData having incorrect time stamps(#26496079). All of the time stamps in the previous comment are calculated using the following methods:

Get the date for when the device was last rebooted:

func lastDeviceRebootDate() -> NSDate {
    let timeIntervalSinceLastDeviceReboot = NSProcessInfo.processInfo().systemUptime
    return NSDate(timeInterval: -timeIntervalSinceLastDeviceReboot, sinceDate: NSDate())
}

Get the time interval since last device reboot for any date.

func timeIntervalSinceLastDeviceRebootForDate(date: NSDate) -> NSTimeInterval {
    return date.timeIntervalSinceDate(self.lastDeviceRebootDate())
}

Let me know if you need further clarification and I can add more detail about where I get each time stamp.

By jasdeep.saini at June 6, 2016, 7:21 p.m. (reply...)

Response to request for more information

In the sample project I attached to this bug, I take the following steps to produce this issue:

  1. Start Recording accelerometer data for 4 minutes.
  2. Wait four minutes for recording to occur.
  3. Ask for the Accelerometer data from the first minute data was recorded. The documentation states that it can take up to 3 minutes to retrieve data, so I want all of my requested data to be more than 3 minutes old.

Here are some sample results when I run these steps:

Actual:

2016-06-06 13:54:03.885 CMSensorRecorderBug WatchKit Extension[176:6456] Started Recording 1026.892551 2016-06-06 13:59:36.872 CMSensorRecorderBug WatchKit Extension[176:6456] Retrieving Sensor Data From: 2016-06-06 18:54:03 +0000 (984.445951) To: 2016-06-06 18:55:03 +0000 1064.724539) 2016-06-06 13:59:37.080 CMSensorRecorderBug WatchKit Extension[176:6456] Number of Readings: 2942 2016-06-06 13:59:37.081 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of last recorded data: 1064.287449 2016-06-06 13:59:37.082 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of requested end date: 1064.724545 2016-06-06 13:59:37.083 CMSensorRecorderBug WatchKit Extension[176:6456] Data gap in seconds: 0.437096 2016-06-06 13:59:53.775 CMSensorRecorderBug WatchKit Extension[176:6456] Started Recording 1354.608590

Expected:

This one is actually pretty good. I requested the end date to have a time stamp of 1064.724545. The last CMRecordedAccelerometerData returned by CMSensorRecorder had a time stamp of 1064.287449. So the gap between the time stamp for the requested end time and actual end time was 0.437096 seconds.

Actual:

2016-06-06 13:59:53.775 CMSensorRecorderBug WatchKit Extension[176:6456] Started Recording 1354.608590 2016-06-06 14:04:17.824 CMSensorRecorderBug WatchKit Extension[176:6456] Retrieving Sensor Data From: 2016-06-06 18:59:53 +0000 (1354.611747) To: 2016-06-06 19:00:53 +0000 1414.611771) 2016-06-06 14:04:18.007 CMSensorRecorderBug WatchKit Extension[176:6456] Number of Readings: 2802 2016-06-06 14:04:18.008 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of last recorded data: 1409.601807 2016-06-06 14:04:18.008 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of requested end date: 1414.611766 2016-06-06 14:04:18.009 CMSensorRecorderBug WatchKit Extension[176:6456] Data gap in seconds: 5.009959

Expected:

Lost 5 seconds on this one. I requested an end time stamp of 1414.611771 and the last CMRecordedAccelerometerData returned by the CMSensorRecorder had a time stamp of 1409.601807.

Actual:

2016-06-06 14:04:30.337 CMSensorRecorderBug WatchKit Extension[176:6456] Started Recording 1631.173022 2016-06-06 14:08:54.408 CMSensorRecorderBug WatchKit Extension[176:6456] Retrieving Sensor Data From: 2016-06-06 19:04:30 +0000 (1631.176180) To: 2016-06-06 19:05:30 +0000 1691.176202) 2016-06-06 14:08:54.589 CMSensorRecorderBug WatchKit Extension[176:6456] Number of Readings: 2751 2016-06-06 14:08:54.593 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of last recorded data: 1686.462372 2016-06-06 14:08:54.596 CMSensorRecorderBug WatchKit Extension[176:6456] Time stamp of requested end date: 1691.176197 2016-06-06 14:08:54.597 CMSensorRecorderBug WatchKit Extension[176:6456] Data gap in seconds: 4.713825

Expected:

Lost 4.713825 seconds on this one. I requested an end time stamp of 1691.176202 and the last CMRecordedAccelerometerData returned by the CMSensorRecorder had a time stamp of 1686.462372.

By jasdeep.saini at June 6, 2016, 7:21 p.m. (reply...)

Request for more information from Apple

Expected Results: The gap between the CMRecordedAccelerometerData object's startDate & the requested toDate is usually between 0-3 seconds.

Actual Results: The gap between the last CMRecordedAccelerometerData object's startDate & the requested toDate will be closer to 0 than to 3 seconds.

————————

  1. Can you clarify the expected and actual behavior? Specifically where does seconds come from?

Please provide your response or results by updating your bug report. If uploading files, please compress first.

By jasdeep.saini at June 6, 2016, 7:20 p.m. (reply...)

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!