Skip to content

Commit

Permalink
Merge pull request #5719 from vector-im/feature/bma/improved_logs
Browse files Browse the repository at this point in the history
Do not cancel the current sync request when the app goes to background
  • Loading branch information
bmarty authored Apr 12, 2022
2 parents f7e8c01 + 03d6aa8 commit 836a12d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions changelog.d/5719.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not cancel the current incremental sync request and treatment when the app goes to background
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,11 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
sum.key = reaction
sum.firstTimestamp = event.originServerTs ?: 0
if (isLocalEcho) {
Timber.v("Adding local echo reaction $reaction")
Timber.v("Adding local echo reaction")
sum.sourceLocalEcho.add(txId)
sum.count = 1
} else {
Timber.v("Adding synced reaction $reaction")
Timber.v("Adding synced reaction")
sum.count = 1
sum.sourceEvents.add(reactionEventId)
}
Expand All @@ -613,16 +613,16 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
// check if it's not the sync of a local echo
if (!isLocalEcho && sum.sourceLocalEcho.contains(txId)) {
// ok it has already been counted, just sync the list, do not touch count
Timber.v("Ignoring synced of local echo for reaction $reaction")
Timber.v("Ignoring synced of local echo for reaction")
sum.sourceLocalEcho.remove(txId)
sum.sourceEvents.add(reactionEventId)
} else {
sum.count += 1
if (isLocalEcho) {
Timber.v("Adding local echo reaction $reaction")
Timber.v("Adding local echo reaction")
sum.sourceLocalEcho.add(txId)
} else {
Timber.v("Adding synced reaction $reaction")
Timber.v("Adding synced reaction")
sum.sourceEvents.add(reactionEventId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ internal class DefaultFetchThreadTimelineTask @Inject constructor(
sum = realm.createObject(ReactionAggregatedSummaryEntity::class.java)
sum.key = reaction
sum.firstTimestamp = event.originServerTs ?: 0
Timber.v("Adding synced reaction $reaction")
Timber.v("Adding synced reaction")
sum.count = 1
// reactionEventId not included in the /relations API
// sum.sourceEvents.add(reactionEventId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
isInitialSync: Boolean,
aggregator: SyncResponsePostTreatmentAggregator,
reporter: ProgressReporter? = null) {
Timber.v("Execute transaction from $this")
handleRoomSync(realm, HandlingStrategy.JOINED(roomsSyncResponse.join), isInitialSync, aggregator, reporter)
handleRoomSync(realm, HandlingStrategy.INVITED(roomsSyncResponse.invite), isInitialSync, aggregator, reporter)
handleRoomSync(realm, HandlingStrategy.LEFT(roomsSyncResponse.leave), isInitialSync, aggregator, reporter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,

fun pause() = synchronized(lock) {
if (isStarted) {
Timber.tag(loggerTag.value).d("Pause sync...")
Timber.tag(loggerTag.value).d("Pause sync... Not cancelling incremental sync")
isStarted = false
retryNoNetworkTask?.cancel()
syncScope.coroutineContext.cancelChildren()
// Do not cancel the current incremental sync.
// Incremental sync can be long and it requires the user to wait for the treatment to end,
// else all is restarted from the beginning each time the user moves the app to foreground.
}
}

Expand Down
4 changes: 2 additions & 2 deletions tools/hs_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@
print("# " + item[0] + " (" + item[1] + ")")
print("====================================================================================================")
if item[2]:
os.system("curl -s -X GET '" + item[1] + "' | python -m json.tool")
os.system("curl -s -X GET '" + item[1] + "' | python3 -m json.tool")
else:
os.system("curl -s -X POST --data $'{}' '" + item[1] + "' | python -m json.tool")
os.system("curl -s -X POST --data $'{}' '" + item[1] + "' | python3 -m json.tool")
14 changes: 7 additions & 7 deletions vector/src/main/java/im/vector/app/VectorApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ class VectorApplication :
val sdkVersion = Matrix.getSdkVersion()
val date = SimpleDateFormat("MM-dd HH:mm:ss.SSSZ", Locale.US).format(Date())

Timber.v("----------------------------------------------------------------")
Timber.v("----------------------------------------------------------------")
Timber.v(" Application version: $appVersion")
Timber.v(" SDK version: $sdkVersion")
Timber.v(" Local time: $date")
Timber.v("----------------------------------------------------------------")
Timber.v("----------------------------------------------------------------\n\n\n\n")
Timber.d("----------------------------------------------------------------")
Timber.d("----------------------------------------------------------------")
Timber.d(" Application version: $appVersion")
Timber.d(" SDK version: $sdkVersion")
Timber.d(" Local time: $date")
Timber.d("----------------------------------------------------------------")
Timber.d("----------------------------------------------------------------\n\n\n\n")
}

override fun attachBaseContext(base: Context) {
Expand Down

0 comments on commit 836a12d

Please sign in to comment.