Fix launch crash when MetricKit delivers a diagnostic (#16)

DebugLog.write is called from any thread, but its relay assumed the
main actor. MetricKit delivers payloads on a background queue, so
CrashReports.didReceive trapped in MainActor.assumeIsolated on launch,
and every crash queued another payload for the next launch.


Claude-Session: https://claude.ai/code/session_01KN6Wd5bdgWERis2b4x9Rm3

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Eliot AndresandClaude Opus 5.5 authored and GitHub committed 2026-10-17 20:35:10 +08:00
1 parent ff2e228087
commit 6dec6a60ec
1 file changed
+3 -1
+3 -1
View File
@@ -92,7 +92,9 @@ import UIKit
pointer.screenAspect = { DeviceScreen.aspect }
pointer.locate = { [weak self] jpeg in await self?.locatePointer(jpeg) }
DebugLog.relay = { [weak self] line in
MainActor.assumeIsolated { if !MockMode.on { self?.board.commands.relayLog(line) } }
// DebugLog.write runs on any thread (MetricKit delivers crash reports on a background queue).
let relay = { MainActor.assumeIsolated { if !MockMode.on { self?.board.commands.relayLog(line) } } }
Thread.isMainThread ? relay() : DispatchQueue.main.async(execute: relay)
}
board.commands.onAppCommand = { [weak self] line in self?.handleAppCommand(line) }
DebugLog.write("app launched \(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "")"