Skip to content

Commit 2828664

Browse files
Improved thread-safety and reconnection reliability for hasPublished flag. (#814)
1 parent df9e779 commit 2828664

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Improve thread-safety and reconnection reliability for hasPublished flag.

livekit-android-sdk/src/main/java/io/livekit/android/room/RTCEngine.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ internal constructor(
200200
@Volatile
201201
private var isClosed = true
202202

203+
@Volatile
203204
private var hasPublished = false
204205

205206
private var coroutineScope = CloseableCoroutineScope(SupervisorJob() + ioDispatcher)
@@ -676,12 +677,14 @@ internal constructor(
676677
}
677678

678679
internal fun negotiatePublisher() {
680+
// Mark intent to publish before checking Signal state so reconnect() can
681+
// re-trigger negotiation even if the first attempt occurs before Signal connects.
682+
hasPublished = true
683+
679684
if (!client.isConnected) {
680685
return
681686
}
682687

683-
hasPublished = true
684-
685688
coroutineScope.launch {
686689
if (negotiatePublisherMutex.tryLock()) {
687690
try {

0 commit comments

Comments
 (0)