diff --git a/SignalMessaging/Notifications/UserNotificationsAdaptee.swift b/SignalMessaging/Notifications/UserNotificationsAdaptee.swift index 8d9d662a2a..ed53e14b56 100644 --- a/SignalMessaging/Notifications/UserNotificationsAdaptee.swift +++ b/SignalMessaging/Notifications/UserNotificationsAdaptee.swift @@ -226,22 +226,42 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee { } var contentToUse: UNNotificationContent = content + let postNotification = { + let request = UNNotificationRequest(identifier: notificationIdentifier, content: contentToUse, trigger: trigger) + + if DebugFlags.internalLogging { + Logger.info("presenting notification with identifier: \(notificationIdentifier)") + } + self.notificationCenter.add(request) { (error: Error?) in + if let error = error { + owsFailDebug("Error: \(error)") + return + } + } + } #if swift(>=5.5) // TODO Temporary for Xcode 12 support. if #available(iOS 15, *), let interaction = interaction { if DebugFlags.internalLogging { Logger.info("Will donate interaction") } + let group = DispatchGroup() + group.enter() interaction.donate(completion: { error in - if DebugFlags.internalLogging { - Logger.info("Did donate interaction") - } - guard let error = error else { + if DebugFlags.internalLogging { Logger.info("Did donate interaction") } + + group.leave() + + if let error = error { + owsFailDebug("Failed to donate incoming message intent \(error)") return } - owsFailDebug("Failed to donate incoming message intent \(error)") }) + if case .timedOut = group.wait(timeout: .now() + 1.0) { + Logger.warn("Timed out donating intent") + } + if DebugFlags.internalLogging { Logger.info("Will update notification content with intent") } @@ -256,20 +276,13 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee { owsFailDebug("Failed to update UNNotificationContent for comm style notification") } } + + postNotification() } + #else + postNotification() #endif - let request = UNNotificationRequest(identifier: notificationIdentifier, content: contentToUse, trigger: trigger) - - if DebugFlags.internalLogging { - Logger.info("presenting notification with identifier: \(notificationIdentifier)") - } - notificationCenter.add(request) { (error: Error?) in - if let error = error { - owsFailDebug("Error: \(error)") - return - } - } } private var pendingCancelations = Set() { diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index bd98805c38..3aa0064b4c 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -214,7 +214,7 @@ class GRDBFullTextSearchFinder: NSObject { private static let serialQueue = DispatchQueue(label: "org.signal.fts") // This should only be accessed on serialQueue. - private static let ftsCache = LRUCache(maxSize: 128) + private static let ftsCache = LRUCache(maxSize: 128, nseMaxSize: 16) private class func cacheKey(collection: String, uniqueId: String) -> String { return "\(collection).\(uniqueId)" diff --git a/SignalServiceKit/src/Util/OWSFormat.swift b/SignalServiceKit/src/Util/OWSFormat.swift index ad29bcf36f..684225b770 100644 --- a/SignalServiceKit/src/Util/OWSFormat.swift +++ b/SignalServiceKit/src/Util/OWSFormat.swift @@ -14,7 +14,7 @@ public class OWSFormat: NSObject { // user changes a system setting that would affect // formatting behavior. private static let shortNameComponentsCache = LRUCache(maxSize: 512, - nseMaxSize: 0, + nseMaxSize: 64, shouldEvacuateInBackground: true) @objc