Open
Description
When my app enters the background, its crashing with this:
didEnterBackground()
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__SwiftValue)'
*** First throw call stack:
(0x1918a47cc 0x18eb772e4 0x1904a1e90 0x1904a1248 0x1918466b0 0x1918afdb4 0x1904a2a24 0x1904857fc 0x190485688 0x1055ea5fc 0x1055eaa88 0x19ab96ad8 0x19ab96ab4 0x19ab96a1c 0x19ab96940 0x19ab96918 0x10353a71c 0x10354bf04 0x19ab986a4 0x19ab97f78 0x19ab97c0c 0x1055ea44c 0x1055efc70 0x1055efcb8 0x1918732f4 0x191873210 0x191873158 0x19187170c 0x190494ea4 0x195148204 0x1943940ac 0x195147fe4 0x1943db158 0x19421e59c 0x1943db848 0x1943db558 0x194187178 0x19415580c 0x194155134 0x194154ab4 0x1941540ec 0x19421fb14 0x19483280c 0x19421e01c 0x1942dd824 0x1942dd404 0x1aae641bc 0x1aae63d6c 0x1aae333c8 0x1aae41db8 0x1aae41c44 0x1aae46114 0x10353a71c 0x10353e13c 0x1aae43300 0x1aae43280 0x1aae43158 0x191878328 0x1918782bc 0x191875dc0 0x191874fbc 0x191874830 0x1dd8541c4 0x1943daeb0 0x1944895b4 0x195fddf98 0x195fbe664 0x195fc1490 0x105046578 0x105046628 0x1b7262ec8)
libc++abi: terminating due to uncaught exception of type NSException
The problem seems to emanate from this call:
@objc func didEnterBackground() {
if config.isDebug {
print(#function)
}
sendTimer?.invalidate()
sendTimer = nil
cache.backupCache()
}
and something here is throwing an exception:
func backupCache() {
queue.sync(flags: .barrier) {
do {
let data = try JSONSerialization.data(withJSONObject: cachedLogs)
try data.write(to: LogsCache.fileURL())
self.cachedLogs = []
} catch {
if isDebug {
print("Error saving Logs cache.")
}
}
}
}
Any ideas or workarounds?
Metadata
Metadata
Assignees
Labels
No labels