fix: dispose PeerConnection on call end to release ICE ports
All checks were successful
Android Kernel Build / build (push) Successful in 21m43s

close() alone does not free native WebRTC resources (ICE agent,
ports, threads). Without dispose() the old PC holds ports for ~30s,
blocking the next call from connecting.
This commit is contained in:
2026-04-01 17:42:25 +05:00
parent 89ad59b1f8
commit 7beb722c65

View File

@@ -871,7 +871,11 @@ object CallManager {
runCatching { localAudioTrack?.setEnabled(false) } runCatching { localAudioTrack?.setEnabled(false) }
runCatching { localAudioTrack?.dispose() } runCatching { localAudioTrack?.dispose() }
runCatching { audioSource?.dispose() } runCatching { audioSource?.dispose() }
// close() stops media but does NOT release native resources (ICE agent,
// ports, OWTF threads). Without dispose() the old PC keeps ports bound
// for ~30 s, blocking the next call from connecting.
runCatching { peerConnection?.close() } runCatching { peerConnection?.close() }
runCatching { peerConnection?.dispose() }
localAudioTrack = null localAudioTrack = null
audioSource = null audioSource = null
peerConnection = null peerConnection = null