Skip to content

Commit 83bf80f

Browse files
authored
Merge pull request #1854 from SimonBrandner/release/fix/glare/18538
[Release] Fix glare related regressions
2 parents 67434bc + b9e5417 commit 83bf80f

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

src/webrtc/call.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ export class MatrixCall extends EventEmitter {
535535
this.emit(CallEvent.FeedsChanged, this.feeds);
536536
}
537537

538+
// TODO: Find out what is going on here
538539
// why do we enable audio (and only audio) tracks here? -- matthew
539540
setTracksEnabled(stream.getAudioTracks(), true);
540541

@@ -708,8 +709,6 @@ export class MatrixCall extends EventEmitter {
708709
this.getUserMediaFailed(e);
709710
return;
710711
}
711-
} else if (this.localUsermediaStream) {
712-
this.gotUserMediaForAnswer(this.localUsermediaStream);
713712
} else if (this.waitForLocalAVStream) {
714713
this.setState(CallState.WaitLocalMedia);
715714
}
@@ -721,14 +720,10 @@ export class MatrixCall extends EventEmitter {
721720
* @param {MatrixCall} newCall The new call.
722721
*/
723722
replacedBy(newCall: MatrixCall) {
724-
logger.debug(this.callId + " being replaced by " + newCall.callId);
725723
if (this.state === CallState.WaitLocalMedia) {
726724
logger.debug("Telling new call to wait for local media");
727725
newCall.waitForLocalAVStream = true;
728-
} else if (this.state === CallState.CreateOffer) {
729-
logger.debug("Handing local stream to new call");
730-
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
731-
} else if (this.state === CallState.InviteSent) {
726+
} else if ([CallState.CreateOffer, CallState.InviteSent].includes(this.state)) {
732727
logger.debug("Handing local stream to new call");
733728
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
734729
}
@@ -1029,7 +1024,6 @@ export class MatrixCall extends EventEmitter {
10291024
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
10301025
this.setState(CallState.CreateOffer);
10311026

1032-
logger.info("Got local AV stream with id " + this.localUsermediaStream.id);
10331027
logger.debug("gotUserMediaForInvite -> " + this.type);
10341028
// Now we wait for the negotiationneeded event
10351029
};
@@ -1087,9 +1081,6 @@ export class MatrixCall extends EventEmitter {
10871081
}
10881082

10891083
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
1090-
1091-
logger.info("Got local AV stream with id " + this.localUsermediaStream.id);
1092-
10931084
this.setState(CallState.CreateAnswer);
10941085

10951086
let myAnswer;

src/webrtc/callEventHandler.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class CallEventHandler {
8080
continue;
8181
}
8282
try {
83-
this.handleCallEvent(e);
83+
await this.handleCallEvent(e);
8484
} catch (e) {
8585
logger.error("Caught exception handling call event", e);
8686
}
@@ -100,7 +100,7 @@ export class CallEventHandler {
100100

101101
if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
102102
// add an event listener for once the event is decrypted.
103-
event.once("Event.decrypted", () => {
103+
event.once("Event.decrypted", async () => {
104104
if (!this.eventIsACall(event)) return;
105105

106106
if (this.callEventBuffer.includes(event)) {
@@ -110,7 +110,7 @@ export class CallEventHandler {
110110
// This one wasn't buffered so just run the event handler for it
111111
// straight away
112112
try {
113-
this.handleCallEvent(event);
113+
await this.handleCallEvent(event);
114114
} catch (e) {
115115
logger.error("Caught exception handling call event", e);
116116
}
@@ -128,7 +128,7 @@ export class CallEventHandler {
128128
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
129129
}
130130

131-
private handleCallEvent(event: MatrixEvent) {
131+
private async handleCallEvent(event: MatrixEvent) {
132132
const content = event.getContent();
133133
const type = event.getType() as EventType;
134134
const weSentTheEvent = event.getSender() === this.client.credentials.userId;
@@ -169,7 +169,7 @@ export class CallEventHandler {
169169
}
170170

171171
call.callId = content.call_id;
172-
call.initWithInvite(event);
172+
await call.initWithInvite(event);
173173
this.calls.set(call.callId, call);
174174

175175
// if we stashed candidate events for that call ID, play them back now
@@ -201,9 +201,11 @@ export class CallEventHandler {
201201
// we've got an invite, pick the incoming call because we know
202202
// we haven't sent our invite yet otherwise, pick whichever
203203
// call has the lowest call ID (by string comparison)
204-
if (existingCall.state === CallState.WaitLocalMedia ||
205-
existingCall.state === CallState.CreateOffer ||
206-
existingCall.callId > call.callId) {
204+
if (
205+
existingCall.state === CallState.WaitLocalMedia ||
206+
existingCall.state === CallState.CreateOffer ||
207+
existingCall.callId > call.callId
208+
) {
207209
logger.log(
208210
"Glare detected: answering incoming call " + call.callId +
209211
" and canceling outgoing call " + existingCall.callId,

0 commit comments

Comments
 (0)