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
5 changes: 5 additions & 0 deletions .changeset/fix-hasPublished-thread-safety.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"client-sdk-android": patch
---

Improve thread-safety and reconnection reliability for hasPublished flag.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ internal constructor(
@Volatile
private var isClosed = true

@Volatile
private var hasPublished = false

private var coroutineScope = CloseableCoroutineScope(SupervisorJob() + ioDispatcher)
Expand Down Expand Up @@ -676,12 +677,14 @@ internal constructor(
}

internal fun negotiatePublisher() {
// Mark intent to publish before checking Signal state so reconnect() can
// re-trigger negotiation even if the first attempt occurs before Signal connects.
hasPublished = true

if (!client.isConnected) {
return
}

hasPublished = true

coroutineScope.launch {
if (negotiatePublisherMutex.tryLock()) {
try {
Expand Down