From d1a4683bc332bfdd4ff95578f59320227d4cec15 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 31 May 2024 18:07:37 +1000 Subject: [PATCH] Worked on fixing the main libQuic crashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Revert logic to stop voice messages from playing when their associated message disappears • Updated the libSession build script to pass through the build type (so we get debug libSession builds when doing debug builds) • Fixed a couple of issues in libSession around recovering network connectivity --- LibSession-Util | 2 +- Scripts/build_libSession_util.sh | 5 ++++- .../Calls/Call Management/SessionCallManager.swift | 3 ++- Session/Conversations/ConversationViewModel.swift | 10 ---------- Session/Meta/AppDelegate.swift | 12 ++++++++---- Session/Meta/SessionApp.swift | 2 +- .../NotificationServiceExtension.swift | 10 +++++----- SessionShareExtension/ThreadPickerVC.swift | 8 ++++---- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/LibSession-Util b/LibSession-Util index b66e54b25..d0b03ecf7 160000 --- a/LibSession-Util +++ b/LibSession-Util @@ -1 +1 @@ -Subproject commit b66e54b25805a3edbf5c09fafa2c486b18766383 +Subproject commit d0b03ecf7d17e365edb077d888e926c88ef5d593 diff --git a/Scripts/build_libSession_util.sh b/Scripts/build_libSession_util.sh index d248a2ab5..b3841a28b 100755 --- a/Scripts/build_libSession_util.sh +++ b/Scripts/build_libSession_util.sh @@ -192,9 +192,11 @@ fi rm -rf "${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_output.log" submodule_check=ON +build_type="Release" if [ "$CONFIGURATION" == "Debug" ]; then submodule_check=OFF + build_type="Debug" fi echo "CMake build logs: ${TARGET_BUILD_DIR}/libSessionUtil/libsession_util_output.log" @@ -219,7 +221,8 @@ for i in "${!TARGET_ARCHS[@]}"; do -DBUILD_TESTS=OFF \ -DBUILD_STATIC_DEPS=ON \ -DENABLE_VISIBILITY=ON \ - -DSUBMODULE_CHECK=$submodule_check + -DSUBMODULE_CHECK=$submodule_check \ + -DCMAKE_BUILD_TYPE=$build_type # Capture the exit status of the ./utils/static-bundle.sh command EXIT_STATUS=$? diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index 111769920..585cd2ce8 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -197,8 +197,9 @@ public final class SessionCallManager: NSObject, CallManagerProtocol { // Stop all jobs except for message sending and when completed suspend the database JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend, using: dependencies) { - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() } } } diff --git a/Session/Conversations/ConversationViewModel.swift b/Session/Conversations/ConversationViewModel.swift index ac6497d2f..9a17d64d8 100644 --- a/Session/Conversations/ConversationViewModel.swift +++ b/Session/Conversations/ConversationViewModel.swift @@ -442,16 +442,6 @@ public class ConversationViewModel: OWSAudioPlayerDelegate { .filter { !$0.cellType.isPostProcessed } // Remove headers and other .sorted { lhs, rhs -> Bool in lhs.timestampMs < rhs.timestampMs } - // If we are currently playing a voice message we should make sure it hasn't been deleted and, if - // it has, we should stop playing the audio (this is mostly to catch the case where a message is - // deleted due to a disappearing messages setting) - if - let audioPlayingInteractionId: Int64 = currentPlayingInteraction.wrappedValue, - !sortedData.contains(where: { $0.id == audioPlayingInteractionId }) - { - self.stopAudio() - } - // We load messages from newest to oldest so having a pageOffset larger than zero means // there are newer pages to load return [ diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 411bfaf15..03c7d2379 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -211,8 +211,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // Stop all jobs except for message sending and when completed suspend the database JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend, using: dependencies) { if !self.hasCallOngoing() { - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.info("[AppDelegate] completed network and database shutdowns.") + Log.flush() } } } @@ -292,14 +294,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD guard BackgroundPoller.isValid else { return } + Log.info("Background poll failed due to manual timeout") BackgroundPoller.isValid = false if Singleton.hasAppContext && Singleton.appContext.isInBackground { - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() } - Log.info("Background poll failed due to manual timeout") completionHandler(.failed) } @@ -322,8 +325,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD BackgroundPoller.isValid = false if Singleton.hasAppContext && Singleton.appContext.isInBackground { - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() } cancelTimer.invalidate() diff --git a/Session/Meta/SessionApp.swift b/Session/Meta/SessionApp.swift index b0b75c576..f122436c9 100644 --- a/Session/Meta/SessionApp.swift +++ b/Session/Meta/SessionApp.swift @@ -112,7 +112,6 @@ public struct SessionApp { // MARK: - Functions public static func resetAppData(onReset: (() -> ())? = nil) { - Log.flush() LibSession.clearMemoryState() LibSession.clearSnodeCache() LibSession.closeNetworkConnections() @@ -120,6 +119,7 @@ public struct SessionApp { ProfileManager.resetProfileStorage() Attachment.resetAttachmentStorage() AppEnvironment.shared.notificationPresenter.clearAllNotifications() + Log.flush() onReset?() exit(0) diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 3ab8d9463..3a54f3ee4 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -343,15 +343,15 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension }) == false else { return } - Log.info("Complete silently.") - Log.flush() let silentContent: UNMutableNotificationContent = UNMutableNotificationContent() silentContent.badge = Storage.shared .read { db in try Interaction.fetchUnreadCount(db) } .map { NSNumber(value: $0) } .defaulting(to: NSNumber(value: 0)) - Storage.suspendDatabaseAccess() + Log.info("Complete silently.") LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() self.contentHandler!(silentContent) } @@ -416,9 +416,9 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension private func handleFailure(for content: UNMutableNotificationContent, error: NotificationError) { Log.error("Show generic failure message due to error: \(error).") - Log.flush() - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() content.title = "Session" content.body = "APN_Message".localized() diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index e6f98d65c..21aaa460e 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -100,9 +100,9 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView // When the thread picker disappears it means the user has left the screen (this will be called // whether the user has sent the message or cancelled sending) - Log.flush() - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() } @objc func applicationDidBecomeActive(_ notification: Notification) { @@ -314,9 +314,9 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView .receive(on: DispatchQueue.main) .sinkUntilComplete( receiveCompletion: { [weak self] result in - Log.flush() - Storage.suspendDatabaseAccess() LibSession.closeNetworkConnections() + Storage.suspendDatabaseAccess() + Log.flush() activityIndicator.dismiss { } switch result {