You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Handle WebRTC security errors as non-fatal
Fixes https://github.com/vector-im/riot-web/issues/10898 In some restricted modes of Firefox, the WebRTC classes aren't super available: accessing them can cause SecurityErrors to be raised. In these conditions, we should just disable WebRTC support instead of falling apart.
This commit is contained in:
@@ -1370,6 +1370,12 @@ module.exports.createNewMatrixCall = function(client, roomId, options) {
|
||||
return getUserMedia.apply(w.navigator, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// Firefox throws on so little as accessing the RTCPeerConnection when operating in
|
||||
// a secure mode. There's some information at https://bugzilla.mozilla.org/show_bug.cgi?id=1542616
|
||||
// though the concern is that the browser throwing a SecurityError will brick the
|
||||
// client creation process.
|
||||
try {
|
||||
webRtc.RtcPeerConnection = (
|
||||
w.RTCPeerConnection || w.webkitRTCPeerConnection || w.mozRTCPeerConnection
|
||||
);
|
||||
@@ -1388,6 +1394,12 @@ module.exports.createNewMatrixCall = function(client, roomId, options) {
|
||||
} else if (w.RTCPeerConnection) {
|
||||
webRtc.vendor = "generic";
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error("Failed to set up WebRTC object: possible browser interference?");
|
||||
logger.error(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!webRtc.RtcIceCandidate || !webRtc.RtcSessionDescription ||
|
||||
!webRtc.RtcPeerConnection || !webRtc.getUserMedia) {
|
||||
return null; // WebRTC is not supported.
|
||||
|
||||
Reference in New Issue
Block a user