fix(webrtc): stop preview tracks when abandoning pre-connect call (#7074)

This commit is contained in:
sh
2026-06-17 12:28:49 +04:00
committed by GitHub
parent adb3fb8cb2
commit 2d80b2e463
+12 -1
View File
@@ -583,6 +583,8 @@ const processCommand = (function () {
case "capabilities":
console.log("starting outgoing call - capabilities")
if (activeCall) endCall()
// Stop a preview stream from an earlier pre-connect outgoing call being replaced (activeCall may be null here)
stopNotConnectedCall()
let localStream: MediaStream | null = null
try {
@@ -623,7 +625,8 @@ const processCommand = (function () {
if (activeCall) endCall()
// It can be already defined on Android when switching calls (if the previous call was outgoing)
notConnectedCall = undefined
// Stop its preview tracks before clearing, otherwise camera/mic stay live
stopNotConnectedCall()
inactiveCallMediaSources.mic = true
inactiveCallMediaSources.camera = command.media == CallMediaType.Video
inactiveCallMediaSourcesChanged(inactiveCallMediaSources)
@@ -1444,6 +1447,14 @@ const processCommand = (function () {
}
}
// Call on any path that abandons notConnectedCall, otherwise its preview camera/mic tracks stay live.
function stopNotConnectedCall() {
if (notConnectedCall) {
notConnectedCall.localStream.getTracks().forEach((track) => track.stop())
notConnectedCall = undefined
}
}
function resetVideoElements() {
const videos = getVideoElements()
if (!videos) return