diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index d60ed940..5c91f627 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -196,6 +196,9 @@ struct MeshtasticAppleApp: App { switch newScenePhase { case .background: Logger.services.info("🎬 [App] Scene is in the background") + // Stop Session Replay when app goes to background to prevent crashes + // from accessing SwiftUI view hierarchy while backgrounded + SessionReplay.stopRecording() accessoryManager.appDidEnterBackground() do { try persistenceController.container.viewContext.save() @@ -209,6 +212,8 @@ struct MeshtasticAppleApp: App { Logger.services.info("🎬 [App] Scene is inactive") case .active: Logger.services.info("🎬 [App] Scene is active") + // Resume Session Replay when app becomes active + SessionReplay.startRecording() accessoryManager.appDidBecomeActive() @unknown default: Logger.services.error("🍎 [App] Apple must have changed something")