Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not cancel the current sync request when the app goes to background #5719

Merged
merged 5 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -584,11 +584,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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove reaction here? it can be helpful to see which one is being synced

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For privacy reason

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 @@ -600,16 +600,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