diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 6247ab2409..d23a72eaab 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -1758,6 +1758,10 @@ actual object RealmInterop { } } + actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { + return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())) + } + actual fun realm_config_set_sync_config(realmConfiguration: RealmConfigurationPointer, syncConfiguration: RealmSyncConfigurationPointer) { realmc.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr()) } @@ -1980,14 +1984,6 @@ actual object RealmInterop { realmc.realm_object_delete(obj.cptr()) } - actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return LongPointerWrapper(realmc.realm_flx_sync_config_new(user.cptr())).also { ptr -> - // Stop the session immediately when the Realm is closed, so the lifecycle of the - // Sync Client thread is manageable. - realmc.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) - } - } - actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId { val nativeBytes: ShortArray = realmc.realm_sync_subscription_id(subscription.cptr()).bytes val byteArray = ByteArray(nativeBytes.size) diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index 9c7f35a029..ae04710e18 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -3318,11 +3318,7 @@ actual object RealmInterop { } actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer { - return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))).also { ptr -> - // Stop the session immediately when the Realm is closed, so the lifecycle of the - // Sync Client thread is manageable. - realm_wrapper.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY) - } + return CPointerWrapper(realm_wrapper.realm_flx_sync_config_new((user.cptr()))) } actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) { diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt index c7dd207ae4..1846f70928 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncSessionImpl.kt @@ -121,6 +121,7 @@ internal open class SyncSessionImpl( }, progressMode == ProgressMode.INDEFINITELY ) { progressEstimate: Double -> + realm.log.debug("PROGRESS CALLBACK: $progressEstimate") val progress = Progress(progressEstimate) trySendWithBufferOverflowCheck(progress) if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) { diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt index 53728762cf..d68c25c7ce 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/FLXProgressListenerTests.kt @@ -20,6 +20,8 @@ import io.realm.kotlin.Realm import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes import io.realm.kotlin.ext.query import io.realm.kotlin.internal.platform.runBlocking +import io.realm.kotlin.log.LogLevel +import io.realm.kotlin.log.RealmLog import io.realm.kotlin.mongodb.User import io.realm.kotlin.mongodb.sync.Direction import io.realm.kotlin.mongodb.sync.Progress @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.last +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.supervisorScope @@ -146,10 +149,12 @@ class FLXProgressListenerTests { @Test fun uploadProgressListener_changesOnly() = runBlocking { + RealmLog.setLevel(LogLevel.ALL) Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm -> for (i in 0..3) { realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT) realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES) + .onEach { println("PROGRESS LISTENER: $it") } .run { withTimeout(TIMEOUT) { last().let {