Hi, thanks for the reply!
I can attach a redacted crash report below. I've redacted our class and method names, so hopefully that does not make it too difficult to read.
As for reproduction, we can reproduce the iteration, but we cannot get it to crash despite hours of testing. This does align with the fact that this crash only happens to a very small subset of users in the field.
We are querying for at most 10 minutes of data at a time, with none being older than 3 days. I cannot attach an exact query that produces a crash because we cannot reproduce any crashes, but I can paste some of the logic below.
@Published private var dateIntervals: [DateInterval] = [] {
didSet {
storage.save(intervals: dateIntervals)
}
}
func consumeNextDataBatch(length: TimeInterval) -> AccelerationHistoryBatch { // length is always .minutes(10)
dropUnreachableDateIntervals()
guard let firstInterval = dateIntervals.first else {
return .empty
}
if firstInterval.duration <= length {
// The first interval is shorter then our target lenght, no need to further slicing, just return it
return .complete(getAccelerationHistory(for: dateIntervals.removeFirst()))
}
// The next interval is longer then what we need -> need to slice it
let slices = firstInterval.split(at: length)
// We have already checked that this interval can be split at this length so we can safely force unwrap here
dateIntervals[0] = slices.second! // swiftlint:disable:this force_unwrapping
return .partial(getAccelerationHistory(for: slices.first))
}
private func getAccelerationHistory(for interval: DateInterval) -> CMSensorDataList? {
let fromDate = max(interval.start,
clock.currentDate.addingTimeInterval(-TMSensor42Constants.maxHistorySeconds)) // maxHistorySeconds == 60 * 60 * 24 * 3 - 60
let toDate = max(fromDate, interval.end)
return sensorRecorder.accelerometerData(from: fromDate, to: toDate)
}
In summary, we split a date interval to be 10 minutes or less and query that time range with accelerometerData.
Hopefully these attachments have been helpful, let me know if anything else would be useful, thanks!
CMSensorDataList_Crash_Report.txt
Topic:
App & System Services
SubTopic:
Maps & Location
Tags: