Hook up client pausing and resuming next to sync starting and stopping for nightly and debug builds.

This will hopefully close all file descriptors and prevent the system from killing the app in the background.
Reported in https://github.com/matrix-org/matrix-rust-sdk/issues/6366 and implemented in https://github.com/matrix-org/matrix-rust-sdk/pull/6495
This commit is contained in:
Stefan Ceriu
2026-05-14 16:03:13 +03:00
parent 579b63d331
commit 4ff58f8756
2 changed files with 21 additions and 0 deletions
@@ -81,6 +81,7 @@ final class AppSettings {
case focusEventOnNotificationTap
case linkNewDeviceEnabled
case automaticBackPaginationEnabled
case clientPausingAndResumingEnabled
// Doug's tweaks 🔧
case roomListActivityVisibility
@@ -448,6 +449,9 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store))
var automaticBackPaginationEnabled
@UserPreference(key: UserDefaultsKeys.clientPausingAndResumingEnabled, defaultValue: appBuildType != .release, storageType: .volatile)
var clientPausingAndResumingEnabled
@UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType != .release, storageType: .userDefaults(store))
var developerOptionsEnabled
}
@@ -403,6 +403,14 @@ class ClientProxy: ClientProxyProtocol {
MXLog.info("Starting sync")
Task {
if appSettings.clientPausingAndResumingEnabled {
do {
try await client.resume()
} catch {
MXLog.error("Failed resuming client with error: \(error)")
}
}
await syncService.start()
// If we are using OAuth we want to cache the account management URL in volatile memory on the SDK side.
@@ -454,6 +462,15 @@ class ClientProxy: ClientProxyProtocol {
}
await syncService.stop()
if appSettings.clientPausingAndResumingEnabled {
do {
try await client.pause()
} catch {
MXLog.error("Failed pausing client with error: \(error)")
}
}
MXLog.info("Sync stopped")
}
}