mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Fix libdispatch main-thread trap when logging Sentry crash events
Sentry's beforeSend runs on a background queue, but Event.crashLog read UIDevice.current there, which carries a main-thread dispatch assertion and trapped libdispatch. Read the device values on the main thread at setup and pass them into the now-nonisolated crashLog.
This commit is contained in:
@@ -1020,8 +1020,11 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
// Mirror every crash into our own logs (which ship with rageshakes) before it's sent to Sentry.
|
||||
options.beforeSend = { event in
|
||||
if let crashLog = event.crashLog {
|
||||
// Device values are read here on the main thread; beforeSend runs on a background queue.
|
||||
let deviceModel = UIDevice.current.model
|
||||
let systemVersion = UIDevice.current.systemVersion
|
||||
options.beforeSend = { @Sendable event in
|
||||
if let crashLog = event.crashLog(deviceModel: deviceModel, systemVersion: systemVersion) {
|
||||
MXLog.error("Sentry crash event \(event.eventId.sentryIdString):\n\(crashLog)")
|
||||
}
|
||||
return event
|
||||
|
||||
Reference in New Issue
Block a user