Merge branch 'jrose/more-nse-logging'
This commit is contained in:
commit
fc88d23f7e
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -250,9 +250,7 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee {
|
||||
|
||||
let request = UNNotificationRequest(identifier: notificationIdentifier, content: contentToUse, trigger: trigger)
|
||||
|
||||
if DebugFlags.internalLogging {
|
||||
Logger.info("presenting notification with identifier: \(notificationIdentifier)")
|
||||
}
|
||||
Logger.info("presenting notification with identifier: \(notificationIdentifier)")
|
||||
notificationCenter.add(request) { (error: Error?) in
|
||||
if let error = error {
|
||||
owsFailDebug("Error: \(error)")
|
||||
|
||||
@ -206,6 +206,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
runningAndCompletedPromises.append(("MessageProcessorCompletion", promise))
|
||||
return promise
|
||||
}.then(on: .global()) { () -> Promise<Void> in
|
||||
Logger.info("Initial message processing complete.")
|
||||
// Wait until all async side effects of
|
||||
// message processing are complete.
|
||||
let completionPromises: [(String, Promise<Void>)] = [
|
||||
@ -220,7 +221,11 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
// Wait until all sync requests are fulfilled.
|
||||
("Pending sync request", OWSMessageManager.pendingTasksPromise())
|
||||
]
|
||||
let joinedPromise = Promise.when(resolved: completionPromises.map { $0.1 })
|
||||
let joinedPromise = Promise.when(resolved: completionPromises.map { (name, promise) in
|
||||
promise.done(on: .global()) {
|
||||
Logger.info("\(name) complete")
|
||||
}
|
||||
})
|
||||
completionPromises.forEach { runningAndCompletedPromises.append($0) }
|
||||
return joinedPromise.asVoid()
|
||||
}
|
||||
|
||||
@ -806,6 +806,11 @@ extension OWSURLSession: URLSessionDownloadDelegate {
|
||||
completionHandler(.cancel)
|
||||
return
|
||||
}
|
||||
if response.expectedContentLength > 800_000 {
|
||||
let formattedContentLength = OWSFormat.formatFileSize(UInt(response.expectedContentLength))
|
||||
let urlString = response.url.map { String(describing: $0) } ?? "<unknown URL>"
|
||||
Logger.warn("Large response (\(formattedContentLength)) for \(urlString)")
|
||||
}
|
||||
completionHandler(.allow)
|
||||
}
|
||||
|
||||
|
||||
@ -60,12 +60,12 @@ public class LocalDevice: NSObject {
|
||||
mallocAllocations: Int64(statistics.size_allocated)
|
||||
)
|
||||
|
||||
if DebugFlags.internalLogging, CurrentAppContext().isNSE {
|
||||
if CurrentAppContext().isNSE {
|
||||
if result.bytesRemaining > 0 {
|
||||
// If we're running out of free memory, let's start aggressively flushing
|
||||
// our log messages. This way, we don't lose any logs when we're suddenly terminated.
|
||||
// There's a perf cost here, but we're going to be killed soon anyway so it's not a big deal.
|
||||
OWSLogger.aggressiveFlushing = result.bytesRemaining < (1024 * 1024)
|
||||
OWSLogger.aggressiveFlushing = result.bytesRemaining < (4 * 1024 * 1024)
|
||||
} else {
|
||||
// The source of the remaining bits is fairly under documented. In my testing, things
|
||||
// seem to be working as expected. Just to be safe, let's interpret 0 free bytes as invalid
|
||||
|
||||
Loading…
Reference in New Issue
Block a user