Skip to content

Commit ca5ac79

Browse files
authored
Revert hack to only clone streams on safari (#2485)
Reverts #2450 Looks like this wasn't really the problem (although may have made it happens faster) and the actual problem was multiple audio contexts and/or leaking peer connections as fixed in #2484
1 parent f9672cf commit ca5ac79

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

src/webrtc/groupCall.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,6 @@ function getCallUserId(call: MatrixCall): string | null {
146146
return call.getOpponentMember()?.userId || call.invitee || null;
147147
}
148148

149-
/**
150-
* Returns a call feed for passing to a new call in the group call. The media
151-
* This could be either return the passed feed as-is or a clone, depending on the
152-
* platform.
153-
* @returns CallFeed
154-
*/
155-
function feedForNewCallFromFeed(feed: CallFeed): CallFeed {
156-
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
157-
158-
// Safari can't send a MediaStream to multiple sources, so we clone it,
159-
// however cloning mediastreams on Chrome appears to cause the audio renderer
160-
// to become unstable and hang: https://github.com/vector-im/element-call/issues/267
161-
// It's a bit arbitrary what we do for other browsers: I've made Safari the special
162-
// case on a somewhat arbitrary basis.
163-
// To retest later to see if this hack is still necessary:
164-
// * In Safari, you should be able to have a group call with 2 other people and both
165-
// of them see your video stream (either desktop or mobile Safari)
166-
// * In Chrome, you should be able to enter a call and then go to youtube and play
167-
// a video (both desktop & Android Chrome, although in Android you may have to
168-
// open YouTube in incognito mode to avoid being redirected to the app.)
169-
if (isSafari) {
170-
return feed.clone();
171-
}
172-
173-
return feed;
174-
}
175-
176149
export class GroupCall extends TypedEventEmitter<GroupCallEvent, GroupCallEventHandlerMap> {
177150
// Config
178151
public activeSpeakerInterval = 1000;
@@ -598,7 +571,7 @@ export class GroupCall extends TypedEventEmitter<GroupCallEvent, GroupCallEventH
598571

599572
// TODO: handle errors
600573
await Promise.all(this.calls.map(call => call.pushLocalFeed(
601-
feedForNewCallFromFeed(this.localScreenshareFeed),
574+
this.localScreenshareFeed.clone(),
602575
)));
603576

604577
await this.sendMemberStateEvent();
@@ -673,7 +646,7 @@ export class GroupCall extends TypedEventEmitter<GroupCallEvent, GroupCallEventH
673646
this.addCall(newCall);
674647
}
675648

676-
newCall.answerWithCallFeeds(this.getLocalFeeds().map((feed) => feedForNewCallFromFeed(feed)));
649+
newCall.answerWithCallFeeds(this.getLocalFeeds().map((feed) => feed.clone()));
677650
};
678651

679652
/**
@@ -861,7 +834,7 @@ export class GroupCall extends TypedEventEmitter<GroupCallEvent, GroupCallEventH
861834

862835
try {
863836
await newCall.placeCallWithCallFeeds(
864-
this.getLocalFeeds().map(feed => feedForNewCallFromFeed(feed)),
837+
this.getLocalFeeds().map(feed => feed.clone()),
865838
requestScreenshareFeed,
866839
);
867840
} catch (e) {

0 commit comments

Comments
 (0)