Skip to content

Commit

Permalink
common: fix behavior of multiple createLocalDescription calls on fire…
Browse files Browse the repository at this point in the history
…fox (#1078)

* use localDescription property

* debug

* debug

* debug

* cleanup
  • Loading branch information
bjia56 committed Mar 1, 2024
1 parent 625c1d4 commit cb742ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions common/src/rtc-signaling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ export class BrowserSignalingSession implements RTCSignalingSession {
}

if (type === 'offer') {
let offer = await this.pc.createOffer({
let offer: RTCSessionDescriptionInit = this.pc.localDescription;
if (offer) {
// fast path for duplicate calls to createLocalDescription
return toDescription(this.pc.localDescription);
}
offer = await this.pc.createOffer({
offerToReceiveAudio: !!setup.audio,
offerToReceiveVideo: !!setup.video,
});
Expand All @@ -232,7 +237,7 @@ export class BrowserSignalingSession implements RTCSignalingSession {
return toDescription(offer);
await set;
await gatheringPromise;
offer = await this.pc.createOffer({
offer = this.pc.localDescription || await this.pc.createOffer({
offerToReceiveAudio: !!setup.audio,
offerToReceiveVideo: !!setup.video,
});
Expand Down

0 comments on commit cb742ab

Please sign in to comment.