fix: send ICE candidates to all peers and exclude self from peer set
Two bugs caused WebRTC group calls to get stuck in "Connecting": 1. CallController.onLocalIceCandidate() used currentPeerPubKey() which returns only the first peer via firstOrNull(). ICE candidates were gift-wrapped to only one peer; the others never received them. Fixed by iterating over all currentPeerPubKeys(). 2. CallManager.acceptCall() set Connecting.peerPubKeys to groupMembers which includes the local user's own pubkey. This caused currentPeerPubKey() to potentially return self, sending ICE candidates to oneself instead of the caller. Fixed by filtering out signer.pubKey from the peer set. https://claude.ai/code/session_01J5fJx9YbSBx1BsBMctiAm8
This commit is contained in:
@@ -491,13 +491,15 @@ class CallController(
|
|||||||
private fun onLocalIceCandidate(candidate: IceCandidate) {
|
private fun onLocalIceCandidate(candidate: IceCandidate) {
|
||||||
Log.d(TAG) { "Local ICE candidate: ${candidate.sdp.take(50)}" }
|
Log.d(TAG) { "Local ICE candidate: ${candidate.sdp.take(50)}" }
|
||||||
val callId = callManager.currentCallId() ?: return
|
val callId = callManager.currentCallId() ?: return
|
||||||
val peerPubKey = callManager.currentPeerPubKey() ?: return
|
val peerPubKeys = callManager.currentPeerPubKeys()?.takeIf { it.isNotEmpty() } ?: return
|
||||||
val candidateJson = CallIceCandidateEvent.serializeCandidate(candidate.sdp, candidate.sdpMid, candidate.sdpMLineIndex)
|
val candidateJson = CallIceCandidateEvent.serializeCandidate(candidate.sdp, candidate.sdpMid, candidate.sdpMLineIndex)
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
val signer = signerProvider()
|
val signer = signerProvider()
|
||||||
val result = callFactory.createIceCandidate(candidateJson, peerPubKey, callId, signer)
|
for (peerPubKey in peerPubKeys) {
|
||||||
publishWrap(result.wrap)
|
val result = callFactory.createIceCandidate(candidateJson, peerPubKey, callId, signer)
|
||||||
|
publishWrap(result.wrap)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ class CallManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.d("CallManager") { "acceptCall: callId=${current.callId}, transitioning to Connecting, sdpAnswerLength=${sdpAnswer.length}" }
|
Log.d("CallManager") { "acceptCall: callId=${current.callId}, transitioning to Connecting, sdpAnswerLength=${sdpAnswer.length}" }
|
||||||
_state.value = CallState.Connecting(current.callId, current.peerPubKeys(), current.callType)
|
_state.value = CallState.Connecting(current.callId, current.peerPubKeys() - signer.pubKey, current.callType)
|
||||||
cancelTimeout()
|
cancelTimeout()
|
||||||
|
|
||||||
// Include all group members + self so other devices get notified too.
|
// Include all group members + self so other devices get notified too.
|
||||||
|
|||||||
Reference in New Issue
Block a user