From 8f4aaa38145230b75fd542bddd6c0717cbe95ad5 Mon Sep 17 00:00:00 2001 From: Brandon T Date: Thu, 7 Dec 2023 14:50:39 -0500 Subject: [PATCH] Fix crash on active window during fresh install. --- App/iOS/Delegates/SceneDelegate.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/App/iOS/Delegates/SceneDelegate.swift b/App/iOS/Delegates/SceneDelegate.swift index 7ec96982598..1d5de04ac76 100644 --- a/App/iOS/Delegates/SceneDelegate.swift +++ b/App/iOS/Delegates/SceneDelegate.swift @@ -533,12 +533,15 @@ extension SceneDelegate { let activeWindow = SessionWindow.getActiveWindow(context: DataController.swiftUIContext) let activeSession = UIApplication.shared.openSessions .compactMap({ BrowserState.getWindowInfo(from: $0) }) - .first(where: { $0.windowId == activeWindow?.windowId.uuidString }) + .first(where: { $0.windowId != nil && $0.windowId == activeWindow?.windowId.uuidString }) if activeSession != nil { if !UIApplication.shared.supportsMultipleScenes { // iPhones should not create new windows - return (activeWindow!.windowId, false, nil) + if let activeWindow = activeWindow { + // If there's no active window, fall through and create one + return (activeWindow.windowId, false, nil) + } } // An existing window is already active on screen