Skip to content

Commit

Permalink
Merge pull request #4046 from vector-im/feature/bma/incr_sync_investi…
Browse files Browse the repository at this point in the history
…gation

Incr sync investigation
  • Loading branch information
bmarty authored Sep 23, 2021
2 parents cfd37bb + e27fa5d commit b52f2b0
Show file tree
Hide file tree
Showing 30 changed files with 393 additions and 118 deletions.
1 change: 1 addition & 0 deletions changelog.d/4046.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Push and syncs: add debug info on room list and on room detail screen and improves the log format.
1 change: 1 addition & 0 deletions changelog.d/4046.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
InitialSyncProgressService has been renamed to SyncStatusService and its function getInitialSyncProgressStatus() has been renamed to getSyncStatusLive()
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ext.versions = [
'targetCompat' : JavaVersion.VERSION_11,
]

// Ref: https://kotlinlang.org/releases.html
def gradle = "7.0.2"
// Ref: https://kotlinlang.org/releases.html
def kotlin = "1.5.30"
def kotlinCoroutines = "1.5.1"
def dagger = "2.38.1"
Expand Down Expand Up @@ -55,6 +55,8 @@ ext.libs = [
'lifecycleExtensions' : "androidx.lifecycle:lifecycle-extensions:$lifecycle",
'lifecycleJava8' : "androidx.lifecycle:lifecycle-common-java8:$lifecycle",
'lifecycleLivedata' : "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1",
'datastore' : "androidx.datastore:datastore:1.0.0",
'datastorepreferences' : "androidx.datastore:datastore-preferences:1.0.0",
'pagingRuntimeKtx' : "androidx.paging:paging-runtime-ktx:2.1.2",
'coreTesting' : "androidx.arch.core:core-testing:2.1.0",
'testCore' : "androidx.test:core:$androidxTest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package org.matrix.android.sdk.api.logger
*/
open class LoggerTag(_value: String, parentTag: LoggerTag? = null) {

object SYNC : LoggerTag("SYNC")
object VOIP : LoggerTag("VOIP")

val value: String = if (parentTag == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
import org.matrix.android.sdk.api.session.identity.IdentityService
import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
import org.matrix.android.sdk.api.session.media.MediaService
import org.matrix.android.sdk.api.session.openid.OpenIdService
Expand Down Expand Up @@ -75,7 +75,7 @@ interface Session :
ProfileService,
PushRuleService,
PushersService,
InitialSyncProgressService,
SyncStatusService,
HomeServerCapabilitiesService,
SecureStorageService,
AccountService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,33 @@ package org.matrix.android.sdk.api.session.initsync

import androidx.lifecycle.LiveData

interface InitialSyncProgressService {
interface SyncStatusService {

fun getInitialSyncProgressStatus(): LiveData<Status>
fun getSyncStatusLive(): LiveData<Status>

sealed class Status {
object Idle : Status()
/**
* For initial sync
*/
abstract class InitialSyncStatus: Status()

object Idle : InitialSyncStatus()
data class Progressing(
val initSyncStep: InitSyncStep,
val percentProgress: Int = 0
) : Status()
) : InitialSyncStatus()

/**
* For incremental sync
*/
abstract class IncrementalSyncStatus: Status()

object IncrementalSyncIdle : IncrementalSyncStatus()
data class IncrementalSyncParsing(
val rooms: Int,
val toDevice: Int
) : IncrementalSyncStatus()
object IncrementalSyncError : IncrementalSyncStatus()
object IncrementalSyncDone : IncrementalSyncStatus()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.matrix.android.sdk.api.session.file.ContentDownloadStateTracker
import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
import org.matrix.android.sdk.api.session.media.MediaService
import org.matrix.android.sdk.api.session.openid.OpenIdService
Expand Down Expand Up @@ -115,7 +115,7 @@ internal class DefaultSession @Inject constructor(
private val contentUploadProgressTracker: ContentUploadStateTracker,
private val typingUsersTracker: TypingUsersTracker,
private val contentDownloadStateTracker: ContentDownloadStateTracker,
private val initialSyncProgressService: Lazy<InitialSyncProgressService>,
private val syncStatusService: Lazy<SyncStatusService>,
private val homeServerCapabilitiesService: Lazy<HomeServerCapabilitiesService>,
private val accountDataService: Lazy<SessionAccountDataService>,
private val _sharedSecretStorageService: Lazy<SharedSecretStorageService>,
Expand All @@ -141,7 +141,7 @@ internal class DefaultSession @Inject constructor(
PushersService by pushersService.get(),
EventService by eventService.get(),
TermsService by termsService.get(),
InitialSyncProgressService by initialSyncProgressService.get(),
SyncStatusService by syncStatusService.get(),
SecureStorageService by secureStorageService.get(),
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
ProfileService by profileService.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
import org.matrix.android.sdk.api.session.events.EventService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.openid.OpenIdService
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.securestorage.SecureStorageService
Expand Down Expand Up @@ -81,7 +81,7 @@ import org.matrix.android.sdk.internal.session.download.DownloadProgressIntercep
import org.matrix.android.sdk.internal.session.events.DefaultEventService
import org.matrix.android.sdk.internal.session.homeserver.DefaultHomeServerCapabilitiesService
import org.matrix.android.sdk.internal.session.identity.DefaultIdentityService
import org.matrix.android.sdk.internal.session.initsync.DefaultInitialSyncProgressService
import org.matrix.android.sdk.internal.session.initsync.DefaultSyncStatusService
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManager
import org.matrix.android.sdk.internal.session.openid.DefaultOpenIdService
import org.matrix.android.sdk.internal.session.permalinks.DefaultPermalinkService
Expand Down Expand Up @@ -355,7 +355,7 @@ internal abstract class SessionModule {
abstract fun bindEventSenderProcessorAsSessionLifecycleObserver(processor: EventSenderProcessorCoroutine): SessionLifecycleObserver

@Binds
abstract fun bindInitialSyncProgressService(service: DefaultInitialSyncProgressService): InitialSyncProgressService
abstract fun bindSyncStatusService(service: DefaultSyncStatusService): SyncStatusService

@Binds
abstract fun bindSecureStorageService(service: DefaultSecureStorageService): SecureStorageService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ package org.matrix.android.sdk.internal.session.initsync
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.internal.session.SessionScope
import javax.inject.Inject

@SessionScope
internal class DefaultInitialSyncProgressService @Inject constructor()
: InitialSyncProgressService,
internal class DefaultSyncStatusService @Inject constructor()
: SyncStatusService,
ProgressReporter {

private val status = MutableLiveData<InitialSyncProgressService.Status>()
private val status = MutableLiveData<SyncStatusService.Status>()

private var rootTask: TaskInfo? = null

override fun getInitialSyncProgressStatus(): LiveData<InitialSyncProgressService.Status> {
override fun getSyncStatusLive(): LiveData<SyncStatusService.Status> {
return status
}

// Only to be used for incremental sync
fun setStatus(newStatus: SyncStatusService.Status.IncrementalSyncStatus) {
status.postValue(newStatus)
}

/**
* Create a rootTask
*/
Expand Down Expand Up @@ -67,7 +72,7 @@ internal class DefaultInitialSyncProgressService @Inject constructor()
// Update the progress of the leaf and all its parents
leaf.setProgress(progress)
// Then update the live data using leaf wording and root progress
status.postValue(InitialSyncProgressService.Status.Progressing(leaf.initSyncStep, root.currentProgress.toInt()))
status.postValue(SyncStatusService.Status.Progressing(leaf.initSyncStep, root.currentProgress.toInt()))
}
}
}
Expand All @@ -82,13 +87,13 @@ internal class DefaultInitialSyncProgressService @Inject constructor()
// And close it
endedTask.parent.child = null
} else {
status.postValue(InitialSyncProgressService.Status.Idle)
status.postValue(SyncStatusService.Status.Idle)
}
}
}

fun endAll() {
rootTask = null
status.postValue(InitialSyncProgressService.Status.Idle)
status.postValue(SyncStatusService.Status.Idle)
}
}
Loading

0 comments on commit b52f2b0

Please sign in to comment.