Thank you very much for taking the time to write such a detailed explanation. It is much appreciated!
Here's the code where the crash is happening:
NSMutableDictionary *body = [NSMutableDictionary new];
[body setObject:Utils.deviceDict forKey:@"device"];
NSMutableArray *trackingQueueCopy = trackingQueue.copy;
NSMutableArray *locationObjects = [NSMutableArray new];
for(LocationObject *locationObject in trackingQueueCopy) {
NSDictionary *locationDict = @{@"latitude": @(locationObject.location.coordinate.latitude),
@"longitude": @(locationObject.location.coordinate.longitude),
@"locationTimestamp": @(round(locationObject.location.timestamp.timeIntervalSince1970)),
@"altitude": @(locationObject.location.altitude),
@"horizontalAccuracy": @(locationObject.location.horizontalAccuracy),
@"verticalAccuracy": @(locationObject.location.verticalAccuracy),
@"clientTimestamp": @(round(locationObject.dataTimestamp.timeIntervalSince1970)),
@"battery": @(round(locationObject.batteryLevel*100)/100),
@"speed": @(locationObject.location.speed),
@"course": @(locationObject.location.course)
};
[locationObjects addObject:locationDict];
}
[body setObject:locationObjects forKey:@"locations"];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:body options:NSJSONWritingPrettyPrinted error:&error];
The crash occurs in fact on the very last line. But as can be seen on the first line of that snipped, body cannot be nil (at least to my understanding).
My guess is that somehow the content of body cannot be converted into JSON which is causing the crash but I have not been able to figure how how that can happen.
Unfortunately I don't have a specific user who can send a sysdiagnose so I would like to go by your suggestion of reproducing the crash and comparing the offset to the crash reports. But the thing is, I still have no clue where it could happen and therefore how to reproduce.
By looking a this snippet of code, do you see anything suspicious?
Topic:
App & System Services
SubTopic:
General
Tags: