Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(breakout-rooms): prevent double-track-add crash when switching rooms with tab audio

damenchob6c419d2911d
diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.ts
index 70d5a0fe5d..7a60e9e127 100644
--- a/react/features/base/conference/middleware.any.ts
+++ b/react/features/base/conference/middleware.any.ts
@@ -770,7 +770,15 @@ async function _trackAddedOrRemoved(store: IStore, next: Function, action: AnyAc
const audioMixerEffect = new AudioMixerEffect(desktopAudioTrack);
await jitsiTrack.setEffect(audioMixerEffect);
- await conference.replaceTrack(null, jitsiTrack);
+
+ // Only add the track to the conference if it isn't already there. During a breakout room
+ // switch, replaceLocalTrack already called conference.replaceTrack which invoked
+ // _setupNewTrack and pushed the track into rtc.localTracks. A second replaceTrack(null,
+ // track) call would push it again, creating a duplicate that makes setOfferAnswerCycle
+ // fail with "is already in TPC" when the JVB session offer arrives.
+ if (!conference.getLocalTracks().includes(jitsiTrack)) {
+ await conference.replaceTrack(null, jitsiTrack);
+ }
} else {
await _addLocalTracksToConference(conference, [ jitsiTrack ]);
}