From 3887a8902e8c314003a1a4e62ea1249336e996c5 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 3 Feb 2025 16:44:26 +1100 Subject: [PATCH 1/2] Fixed a crash which could occur when leaving the conversation screen --- Session/Meta/MainAppContext.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Session/Meta/MainAppContext.swift b/Session/Meta/MainAppContext.swift index 4f917da59..3ee8d2a59 100644 --- a/Session/Meta/MainAppContext.swift +++ b/Session/Meta/MainAppContext.swift @@ -154,6 +154,12 @@ final class MainAppContext: AppContext { // stringlint:ignore_contents func ensureSleepBlocking(_ shouldBeBlocking: Bool, blockingObjects: [Any]) { + guard Thread.isMainThread else { + return DispatchQueue.main.async { [weak self] in + self?.ensureSleepBlocking(shouldBeBlocking, blockingObjects: blockingObjects) + } + } + if UIApplication.shared.isIdleTimerDisabled != shouldBeBlocking { if shouldBeBlocking { var logString: String = "Blocking sleep because of: \(String(describing: blockingObjects.first))" From e47e0e45f548e4793488ae16d767e6fd99d50b82 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 3 Feb 2025 16:46:20 +1100 Subject: [PATCH 2/2] Added a couple more thread checks just to be safe --- Session/Meta/MainAppContext.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Session/Meta/MainAppContext.swift b/Session/Meta/MainAppContext.swift index 3ee8d2a59..3bb1b9249 100644 --- a/Session/Meta/MainAppContext.swift +++ b/Session/Meta/MainAppContext.swift @@ -133,6 +133,12 @@ final class MainAppContext: AppContext { } func setStatusBarHidden(_ isHidden: Bool, animated isAnimated: Bool) { + guard Thread.isMainThread else { + return DispatchQueue.main.async { [weak self] in + self?.setStatusBarHidden(isHidden, animated: isAnimated) + } + } + UIApplication.shared.setStatusBarHidden(isHidden, with: (isAnimated ? .slide : .none)) } @@ -177,6 +183,12 @@ final class MainAppContext: AppContext { } func setNetworkActivityIndicatorVisible(_ value: Bool) { + guard Thread.isMainThread else { + return DispatchQueue.main.async { [weak self] in + self?.setNetworkActivityIndicatorVisible(value) + } + } + UIApplication.shared.isNetworkActivityIndicatorVisible = value }