From ca8a335adc512de34864f7997247ec0f9d4b0266 Mon Sep 17 00:00:00 2001 From: Kyriakos Sidiropoulos Date: Fri, 17 Jan 2025 21:38:05 +0100 Subject: [PATCH] perf (iOS/all operations): we now launch logging and progress% callbacks in the background so that the file-uploading/downloading aspects will be unimpeded --- .../McuMgrBindingsiOS/IOSFileDownloader.swift | 8 ++++++-- .../McuMgrBindingsiOS/IOSFileUploader.swift | 14 +++++++++----- .../McuMgrBindingsiOS/IOSFirmwareInstaller.swift | 14 +++++++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileDownloader.swift b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileDownloader.swift index 76715b7..c20e2ce 100644 --- a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileDownloader.swift +++ b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileDownloader.swift @@ -192,7 +192,9 @@ public class IOSFileDownloader: NSObject { //@objc dont private func logMessageAdvertisement(_ message: String, _ category: String, _ level: String) { - _listener.logMessageAdvertisement(message, category, level, _remoteFilePathSanitized) + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.logMessageAdvertisement(message, category, level, self._remoteFilePathSanitized) + } } //@objc dont @@ -218,7 +220,9 @@ public class IOSFileDownloader: NSObject { _ progressPercentage: Int, _ averageThroughput: Float32 ) { - _listener.fileDownloadProgressPercentageAndDataThroughputChangedAdvertisement(progressPercentage, averageThroughput) + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.fileDownloadProgressPercentageAndDataThroughputChangedAdvertisement(progressPercentage, averageThroughput) + } } //@objc dont diff --git a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileUploader.swift b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileUploader.swift index 3b18cbc..9c089ac 100644 --- a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileUploader.swift +++ b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFileUploader.swift @@ -258,7 +258,9 @@ public class IOSFileUploader: NSObject { //@objc dont private func logMessageAdvertisement(_ message: String, _ category: String, _ level: String) { - _listener.logMessageAdvertisement(message, category, level, _remoteFilePathSanitized) + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.logMessageAdvertisement(message, category, level, self._remoteFilePathSanitized) + } } //@objc dont @@ -294,10 +296,12 @@ public class IOSFileUploader: NSObject { _ progressPercentage: Int, _ averageThroughput: Float32 ) { - _listener.fileUploadProgressPercentageAndDataThroughputChangedAdvertisement( - progressPercentage, - averageThroughput - ) + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.fileUploadProgressPercentageAndDataThroughputChangedAdvertisement( + progressPercentage, + averageThroughput + ) + } } private func setState(_ newState: EIOSFileUploaderState) { diff --git a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFirmwareInstaller.swift b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFirmwareInstaller.swift index 079f62e..2fe81bd 100644 --- a/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFirmwareInstaller.swift +++ b/Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native/McuMgrBindingsiOS/McuMgrBindingsiOS/IOSFirmwareInstaller.swift @@ -215,7 +215,9 @@ public class IOSFirmwareInstaller: NSObject { //@objc dont private func logMessageAdvertisement(_ message: String, _ category: String, _ level: String) { - _listener.logMessageAdvertisement(message, category, level); + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.logMessageAdvertisement(message, category, level) + } } //@objc dont @@ -245,7 +247,9 @@ public class IOSFirmwareInstaller: NSObject { _ progressPercentage: Int, _ averageThroughput: Float32 ) { - _listener.firmwareUploadProgressPercentageAndDataThroughputChangedAdvertisement(progressPercentage, averageThroughput) + DispatchQueue.global(qos: .background).async { //fire and forget to boost performance + self._listener.firmwareUploadProgressPercentageAndDataThroughputChangedAdvertisement(progressPercentage, averageThroughput) + } } private func setState(_ newState: EIOSFirmwareInstallationState) { @@ -371,9 +375,9 @@ extension IOSFirmwareInstaller: McuMgrLogDelegate { atLevel level: iOSMcuManagerLibrary.McuMgrLogLevel ) { logMessageAdvertisement( - msg, - category.rawValue, - level.name + msg, + category.rawValue, + level.name ) } }