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/fix-publisher-negotiation-race.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"client-sdk-android": patch
---

#721 Fixed publisher negotiation race condition causing ICE timeouts.

Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ internal constructor(
*/
private var configurationLock = Mutex()

/**
* Prevents concurrent publisher negotiations which can cause ICE gathering
* race conditions and connection failures.
*/
private val negotiatePublisherMutex = Mutex()

init {
client.listener = this
}
Expand Down Expand Up @@ -668,7 +674,15 @@ internal constructor(
hasPublished = true

coroutineScope.launch {
publisher?.negotiate?.invoke(getPublisherOfferConstraints())
if (negotiatePublisherMutex.tryLock()) {
try {
publisher?.negotiate?.invoke(getPublisherOfferConstraints())
} finally {
negotiatePublisherMutex.unlock()
}
} else {
LKLog.v { "negotiatePublisher: skipping, negotiation already in progress" }
}
}
}

Expand Down