fix(WebRTCManager, callStore): improve signaling state handling and media track management
- Enhanced ontrack event handling to construct remote streams and avoid duplicate tracks during renegotiation. - Updated negotiation logic to ensure it only occurs when the signaling state is stable and the instance is the initiator. - Added diagnostic logging for offer and answer SDP to assist in debugging video track handling. - Improved rollback logic in callStore to handle signaling state checks more robustly after rollback attempts.
This commit is contained in:
@@ -202,7 +202,7 @@ async function handleIncomingOffer(msg: WSCallSDPMessage, myUserId: string): Pro
|
||||
return;
|
||||
}
|
||||
|
||||
const signalingState = pc.signalingState;
|
||||
let signalingState = pc.signalingState;
|
||||
console.log('[CallStore] Received offer, signalingState:', signalingState);
|
||||
|
||||
// Glare handling: if we're not in stable state, we have a conflict
|
||||
@@ -223,6 +223,16 @@ async function handleIncomingOffer(msg: WSCallSDPMessage, myUserId: string): Pro
|
||||
await webrtcManager.rollback();
|
||||
} catch (err) {
|
||||
console.error('[CallStore] Rollback failed:', err);
|
||||
// If rollback fails because we're already stable, that's fine - just proceed
|
||||
if (pc.signalingState !== 'stable') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Re-check state after rollback
|
||||
signalingState = pc.signalingState;
|
||||
if (signalingState !== 'stable') {
|
||||
console.warn('[CallStore] Not stable after rollback, state:', signalingState);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user