From 83072451202f78e6d90e967adaa127dc4118b250 Mon Sep 17 00:00:00 2001 From: Benoit Marty <benoit@matrix.org> Date: Mon, 11 Jan 2021 18:31:57 +0100 Subject: [PATCH] Fix issue with delay set to 0 --- .../sdk/internal/session/sync/job/SyncService.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt index 9d854229df..16c4095654 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt @@ -166,15 +166,17 @@ abstract class SyncService : Service() { } if (throwable is Failure.NetworkConnection) { // Timeout is not critical, so retry as soon as possible. - val retryDelay = if (isInitialSync || throwable.cause is SocketTimeoutException) { - 0 - } else { - syncDelaySeconds + if (isInitialSync || throwable.cause is SocketTimeoutException) { + // For big accounts, computing init sync response can take time, but Synapse will cache the + // result for the next request. So keep retrying in loop + Timber.w("Timeout during initial sync, retry in loop") + doSync() + return } // Network might be off, no need to reschedule endless alarms :/ preventReschedule = true // Instead start a work to restart background sync when network is on - onNetworkError(sessionId ?: "", isInitialSync, syncTimeoutSeconds, retryDelay) + onNetworkError(sessionId ?: "", isInitialSync, syncTimeoutSeconds, syncDelaySeconds) } // JobCancellation could be caught here when onDestroy cancels the coroutine context if (isRunning.get()) stopMe()