Skip to content
Open
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-screen-capture-connection-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"client-sdk-android": patch
---

Fixed ScreenCaptureConnection suspending forever when bindService fails and crashing when resuming canceled continuations.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,21 @@ internal class ScreenCaptureConnection(private val context: Context) {
}

val intent = Intent(context, ScreenCaptureService::class.java)
context.bindService(intent, connection, BIND_AUTO_CREATE)
return suspendCancellableCoroutine {
val bound = context.bindService(intent, connection, BIND_AUTO_CREATE)
if (!bound) {
throw IllegalStateException("Failed to bind ScreenCaptureService.")
}
return suspendCancellableCoroutine { cont ->
cont.invokeOnCancellation {
synchronized(this) {
queuedConnects.remove(cont)
}
}
synchronized(this) {
if (isBound) {
it.resume(Unit)
cont.resume(Unit)
} else {
queuedConnects.add(it)
queuedConnects.add(cont)
}
}
}
Expand Down