Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/harden-reconnect-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"client-sdk-android": patch
---

Improve reconnection reliability by hardening state flags and synchronizing data channel receive state.

Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ internal constructor(
}
}
}

@Volatile
internal var reconnectType: ReconnectType = ReconnectType.DEFAULT
private var reconnectingJob: Job? = null

@Volatile
private var fullReconnectOnNext = false

private val pendingTrackResolvers: MutableMap<String, Continuation<LivekitModels.TrackInfo>> =
Expand Down Expand Up @@ -192,6 +196,8 @@ internal constructor(
private val reliableReceivedState = TTLMap<String, Int>(RELIABLE_RECEIVE_STATE_TTL_MS)

private var isSubscriberPrimary = false

@Volatile
private var isClosed = true

private var hasPublished = false
Expand Down Expand Up @@ -1327,11 +1333,13 @@ internal constructor(
.build()
}

val dataChannelReceiveStates = this.reliableReceivedState.map { (participantSid, sequence) ->
with(LivekitRtc.DataChannelReceiveState.newBuilder()) {
publisherSid = participantSid
lastSeq = sequence
build()
val dataChannelReceiveStates = synchronized(reliableStateLock) {
this.reliableReceivedState.map { (participantSid, sequence) ->
with(LivekitRtc.DataChannelReceiveState.newBuilder()) {
publisherSid = participantSid
lastSeq = sequence
build()
}
}
}

Expand Down