I'm getting a "RUNNINGBOARD 0xdead10cc" error intermittently when my app is in the background and I'm using Realm database. I suspect the error is related to file locking during database writes. I have tried adding sleep to the write block, but the error has not occurred during testing.
Here's a code snippet of the function I'm using to update my Realm database:
func update(completion: @escaping () -> ()) {
let dispatchGroup = DispatchGroup()
array1 = Array(Set(self.arrayData))
for element in array1 {
dispatchGroup.enter()
element.updateRealmModel {
dispatchGroup.leave()
}
}
dispatchGroup.notify(queue: .main) {
completion()
}
}
and the element function:
func updateRealmModel(completion: @escaping(() -> Void)) {
let primaryKey = self.id
DispatchQueue.global(qos: .userInitiated).async {
let realm = try! Realm()
if let user = realm.object(ofType: Mytype, forPrimaryKey: primaryKey) {
do {
try realm.write {
user.boolField = false
}
} catch let error {
debugPrint(error)
}
}
completion()
}
}
Can anyone help me reproduce and resolve this error? Are there any known issues related to Realm database writes when an app is in the background? I would appreciate any insights or suggestions on how to debug and fix this issue.