From bf09b559dbee4293876a96230804790155d3e32d Mon Sep 17 00:00:00 2001 From: giomfo Date: Thu, 25 Aug 2016 17:18:31 +0200 Subject: [PATCH] Should fix - Sync has got stuck while the app was backgrounded https://github.com/vector-im/vector-ios/issues/506 According to the logs (attached to the emailed report), the applicationDidEnterBackground was ignored during the session state handling. The session was running whereas the app was backgrounded. --- MatrixKit/Models/Account/MXKAccount.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MatrixKit/Models/Account/MXKAccount.m b/MatrixKit/Models/Account/MXKAccount.m index b126943ba..db879c35d 100644 --- a/MatrixKit/Models/Account/MXKAccount.m +++ b/MatrixKit/Models/Account/MXKAccount.m @@ -641,8 +641,9 @@ - (void)pauseInBackgroundTask [initialServerSyncTimer invalidate]; initialServerSyncTimer = nil; - if (mxSession.state == MXSessionStateSyncInProgress) + if (mxSession.state == MXSessionStateSyncInProgress || mxSession.state == MXSessionStateInitialised || mxSession.state == MXSessionStateStoreDataReady) { + NSLog(@"[MXKAccount] Pause is delayed at the end of sync (current state %tu)", mxSession.state); isPauseRequested = YES; } } @@ -984,6 +985,7 @@ - (void)onMatrixSessionStateChange // Check if pause has been requested if (isPauseRequested) { + NSLog(@"[MXKAccount] Apply the pending pause."); [self pauseInBackgroundTask]; return; }