bug fixes

This commit is contained in:
or-else
2023-01-10 16:28:32 -08:00
parent 18dd37b402
commit 640704ee2a
7 changed files with 104 additions and 47 deletions
+27 -11
View File
@@ -325,7 +325,7 @@ class CallPanel extends React.PureComponent {
.then(_ => { .then(_ => {
this.setState({ callInitialSetupComplete: true }, _ => this.drainRemoteIceCandidatesCache()); this.setState({ callInitialSetupComplete: true }, _ => this.drainRemoteIceCandidatesCache());
}) })
.catch(this.reportError); .catch(err => this.reportError(err));
} }
reportError(err) { reportError(err) {
@@ -347,7 +347,7 @@ class CallPanel extends React.PureComponent {
.then(_ => { .then(_ => {
this.props.onSendOffer(this.props.topic, this.props.seq, pc.localDescription.toJSON()); this.props.onSendOffer(this.props.topic, this.props.seq, pc.localDescription.toJSON());
}) })
.catch(this.reportError); .catch(err => this.reportError(err));
} }
handleIceCandidateErrorEvent(event) { handleIceCandidateErrorEvent(event) {
@@ -364,7 +364,12 @@ class CallPanel extends React.PureComponent {
const candidate = new RTCIceCandidate(info.payload); const candidate = new RTCIceCandidate(info.payload);
if (this.state.callInitialSetupComplete) { if (this.state.callInitialSetupComplete) {
this.state.pc.addIceCandidate(candidate) this.state.pc.addIceCandidate(candidate)
.catch(this.reportError); .catch(err => {
if (candidate.candidate) {
this.reportError(err);
}
console.warn("Error adding new ice candidate", candidate, err);
});
} else { } else {
this.remoteIceCandidatesCache.push(candidate); this.remoteIceCandidatesCache.push(candidate);
} }
@@ -373,7 +378,12 @@ class CallPanel extends React.PureComponent {
drainRemoteIceCandidatesCache() { drainRemoteIceCandidatesCache() {
this.remoteIceCandidatesCache.forEach(candidate => { this.remoteIceCandidatesCache.forEach(candidate => {
this.state.pc.addIceCandidate(candidate) this.state.pc.addIceCandidate(candidate)
.catch(this.reportError); .catch(err => {
if (candidate.candidate) {
this.reportError(err);
}
console.warn("Error adding cached ice candidate", candidate, err);
});
}); });
this.remoteIceCandidatesCache = []; this.remoteIceCandidatesCache = [];
} }
@@ -406,18 +416,18 @@ class CallPanel extends React.PureComponent {
} }
handleGetUserMediaError(e) { handleGetUserMediaError(e) {
console.error("Error opening camera and/or microphone", e);
switch(e.name) { switch(e.name) {
case 'NotFoundError': case 'NotFoundError':
// Cannot start the call b/c no camera and/or microphone found. // Cannot start the call b/c no camera and/or microphone found.
this.reportError(e.message); this.reportError(e);
break; break;
case 'SecurityError': case 'SecurityError':
case 'PermissionDeniedError': case 'PermissionDeniedError':
// Do nothing; this is the same as the user canceling the call. // Do nothing; this is the same as the user canceling the call.
break; break;
default: default:
this.reportError(e.message); this.reportError(e);
console.error("Error opening your camera and/or microphone:", e.message);
break; break;
} }
@@ -495,6 +505,10 @@ class CallPanel extends React.PureComponent {
// Ends video track and turns off the camera. // Ends video track and turns off the camera.
muteVideo() { muteVideo() {
if (!this.state.pc || !this.state.dataChannel) {
return;
}
const stream = this.state.localStream; const stream = this.state.localStream;
const t = stream.getVideoTracks()[0]; const t = stream.getVideoTracks()[0];
t.enabled = false; t.enabled = false;
@@ -506,13 +520,15 @@ class CallPanel extends React.PureComponent {
} }
unmuteVideo() { unmuteVideo() {
const pc = this.state.pc; if (!this.state.pc || !this.state.dataChannel) {
return;
}
navigator.mediaDevices.getUserMedia({ video: true }) navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => { .then(stream => {
// Will extract video track from stream and throw stream away, // Will extract video track from stream and throw stream away,
// and replace video track in the media sender. // and replace video track in the media sender.
this.localRef.current.srcObject = null; this.localRef.current.srcObject = null;
const sender = pc.getSenders().find(s => s.track.kind == 'video'); const sender = this.state.pc.getSenders().find(s => s.track.kind == 'video');
const track = stream.getVideoTracks()[0]; const track = stream.getVideoTracks()[0];
// Remote track from new stream. // Remote track from new stream.
stream.removeTrack(track); stream.removeTrack(track);
@@ -524,7 +540,7 @@ class CallPanel extends React.PureComponent {
this.localRef.current.srcObject = this.state.localStream; this.localRef.current.srcObject = this.state.localStream;
this.state.dataChannel.send(VIDEO_UNMUTED_EVENT); this.state.dataChannel.send(VIDEO_UNMUTED_EVENT);
}) })
.catch(this.handleGetUserMediaError) .catch(err => this.handleGetUserMediaError(err))
.finally(_ => { this.setState({videoToggleInProgress: false}); }); // Make sure we redraw the mute/unmute icons (e.g. camera -> camera_off). .finally(_ => { this.setState({videoToggleInProgress: false}); }); // Make sure we redraw the mute/unmute icons (e.g. camera -> camera_off).
} }
@@ -555,7 +571,7 @@ class CallPanel extends React.PureComponent {
render() { render() {
const audioTracks = this.state.localStream && this.state.localStream.getAudioTracks(); const audioTracks = this.state.localStream && this.state.localStream.getAudioTracks();
const videoTracks = !this.state.audioOnly && this.state.localStream && this.state.localStream.getVideoTracks(); const videoTracks = !this.state.audioOnly && this.state.localStream && this.state.localStream.getVideoTracks();
const disabled = !(audioTracks && audioTracks[0]); const disabled = !this.state.pc || !this.state.dataChannel || !(audioTracks && audioTracks[0]);
const audioIcon = audioTracks && audioTracks[0] && audioTracks[0].enabled ? 'mic' : 'mic_off'; const audioIcon = audioTracks && audioTracks[0] && audioTracks[0].enabled ? 'mic' : 'mic_off';
const videoIcon = videoTracks && videoTracks[0] && videoTracks[0].enabled && videoTracks[0].readyState == 'live' ? 'videocam' : 'videocam_off'; const videoIcon = videoTracks && videoTracks[0] && videoTracks[0].enabled && videoTracks[0].readyState == 'live' ? 'videocam' : 'videocam_off';
const peerTitle = clipStr(this.props.title, MAX_PEER_TITLE_LENGTH); const peerTitle = clipStr(this.props.title, MAX_PEER_TITLE_LENGTH);
+32 -12
View File
@@ -7969,6 +7969,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration; this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
this.tinode.onInfoMessage = this.handleInfoMessage; this.tinode.onInfoMessage = this.handleInfoMessage;
this.tinode.onDataMessage = this.handleDataMessage; this.tinode.onDataMessage = this.handleDataMessage;
console.log("handleDataMessage assigned", this.tinode.onDataMessage);
}).then(_ => { }).then(_ => {
if (this.state.desktopAlertsEnabled) { if (this.state.desktopAlertsEnabled) {
this.initFCMessaging().catch(_ => {}); this.initFCMessaging().catch(_ => {});
@@ -8738,6 +8739,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration; this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
this.tinode.onInfoMessage = this.handleInfoMessage; this.tinode.onInfoMessage = this.handleInfoMessage;
this.tinode.onDataMessage = this.handleDataMessage; this.tinode.onDataMessage = this.handleDataMessage;
console.log("handleDataMessage assigned 2", this.tinode.onDataMessage);
this.setState({ this.setState({
serverAddress: serverAddress, serverAddress: serverAddress,
transport: transport, transport: transport,
@@ -8998,6 +9000,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration; this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
this.tinode.onInfoMessage = this.handleInfoMessage; this.tinode.onInfoMessage = this.handleInfoMessage;
this.tinode.onDataMessage = this.handleDataMessage; this.tinode.onDataMessage = this.handleDataMessage;
console.log("handleDataMessage assigned 3", this.tinode.onDataMessage);
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_18__["default"].navigateTo(''); _lib_navigation_js__WEBPACK_IMPORTED_MODULE_18__["default"].navigateTo('');
}); });
}); });
@@ -9351,6 +9354,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
} }
} }
handleDataMessage(data) { handleDataMessage(data) {
console.log("=== TinodeWeb handleDataMessage", data);
if (data.head && data.head.webrtc && data.head.webrtc == _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_HEAD_STARTED) { if (data.head && data.head.webrtc && data.head.webrtc == _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_HEAD_STARTED) {
const topic = this.tinode.getTopic(data.topic); const topic = this.tinode.getTopic(data.topic);
if (topic) { if (topic) {
@@ -10930,7 +10934,7 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
dataChannel: channel dataChannel: channel
}); });
} }
createPeerConnection(withDataChannel) { createPeerConnection() {
const iceServers = this.props.tinode.getServerParam('iceServers', null); const iceServers = this.props.tinode.getServerParam('iceServers', null);
const pc = iceServers ? new RTCPeerConnection({ const pc = iceServers ? new RTCPeerConnection({
iceServers: iceServers iceServers: iceServers
@@ -10963,9 +10967,10 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
this.setState({ this.setState({
callInitialSetupComplete: true callInitialSetupComplete: true
}, _ => this.drainRemoteIceCandidatesCache()); }, _ => this.drainRemoteIceCandidatesCache());
}).catch(this.reportError); }).catch(err => this.reportError(err));
} }
reportError(err) { reportError(err) {
console.log(`Error! '${err.message}'`, err, new Error("stacktrace!"));
this.props.onError(err.message, 'err'); this.props.onError(err.message, 'err');
} }
canSendOffer() { canSendOffer() {
@@ -10980,7 +10985,7 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
return pc.setLocalDescription(offer); return pc.setLocalDescription(offer);
}).then(_ => { }).then(_ => {
this.props.onSendOffer(this.props.topic, this.props.seq, pc.localDescription.toJSON()); this.props.onSendOffer(this.props.topic, this.props.seq, pc.localDescription.toJSON());
}).catch(this.reportError); }).catch(err => this.reportError(err));
} }
handleIceCandidateErrorEvent(event) { handleIceCandidateErrorEvent(event) {
console.warn("ICE candidate error:", event); console.warn("ICE candidate error:", event);
@@ -10993,14 +10998,24 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
handleNewICECandidateMsg(info) { handleNewICECandidateMsg(info) {
const candidate = new RTCIceCandidate(info.payload); const candidate = new RTCIceCandidate(info.payload);
if (this.state.callInitialSetupComplete) { if (this.state.callInitialSetupComplete) {
this.state.pc.addIceCandidate(candidate).catch(this.reportError); this.state.pc.addIceCandidate(candidate).catch(err => {
if (candidate.candidate) {
this.reportError(err);
}
console.warn("Error adding new ice candidate", candidate, err);
});
} else { } else {
this.remoteIceCandidatesCache.push(candidate); this.remoteIceCandidatesCache.push(candidate);
} }
} }
drainRemoteIceCandidatesCache() { drainRemoteIceCandidatesCache() {
this.remoteIceCandidatesCache.forEach(candidate => { this.remoteIceCandidatesCache.forEach(candidate => {
this.state.pc.addIceCandidate(candidate).catch(this.reportError); this.state.pc.addIceCandidate(candidate).catch(err => {
if (candidate.candidate) {
this.reportError(err);
}
console.warn("Error adding cached ice candidate", candidate, err);
});
}); });
this.remoteIceCandidatesCache = []; this.remoteIceCandidatesCache = [];
} }
@@ -11023,16 +11038,16 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
this.forceUpdate(); this.forceUpdate();
} }
handleGetUserMediaError(e) { handleGetUserMediaError(e) {
console.error("Error opening camera and/or microphone", e);
switch (e.name) { switch (e.name) {
case 'NotFoundError': case 'NotFoundError':
this.reportError(e.message); this.reportError(e);
break; break;
case 'SecurityError': case 'SecurityError':
case 'PermissionDeniedError': case 'PermissionDeniedError':
break; break;
default: default:
this.reportError(e.message); this.reportError(e);
console.error("Error opening your camera and/or microphone:", e.message);
break; break;
} }
this.handleCloseClick(); this.handleCloseClick();
@@ -11093,6 +11108,9 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
this.props.onHangup(this.props.topic, this.props.seq); this.props.onHangup(this.props.topic, this.props.seq);
} }
muteVideo() { muteVideo() {
if (!this.state.pc || !this.state.dataChannel) {
return;
}
const stream = this.state.localStream; const stream = this.state.localStream;
const t = stream.getVideoTracks()[0]; const t = stream.getVideoTracks()[0];
t.enabled = false; t.enabled = false;
@@ -11104,12 +11122,14 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
}); });
} }
unmuteVideo() { unmuteVideo() {
const pc = this.state.pc; if (!this.state.pc || !this.state.dataChannel) {
return;
}
navigator.mediaDevices.getUserMedia({ navigator.mediaDevices.getUserMedia({
video: true video: true
}).then(stream => { }).then(stream => {
this.localRef.current.srcObject = null; this.localRef.current.srcObject = null;
const sender = pc.getSenders().find(s => s.track.kind == 'video'); const sender = this.state.pc.getSenders().find(s => s.track.kind == 'video');
const track = stream.getVideoTracks()[0]; const track = stream.getVideoTracks()[0];
stream.removeTrack(track); stream.removeTrack(track);
this.state.localStream.addTrack(track); this.state.localStream.addTrack(track);
@@ -11117,7 +11137,7 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
}).then(_ => { }).then(_ => {
this.localRef.current.srcObject = this.state.localStream; this.localRef.current.srcObject = this.state.localStream;
this.state.dataChannel.send(VIDEO_UNMUTED_EVENT); this.state.dataChannel.send(VIDEO_UNMUTED_EVENT);
}).catch(this.handleGetUserMediaError).finally(_ => { }).catch(err => this.handleGetUserMediaError(err)).finally(_ => {
this.setState({ this.setState({
videoToggleInProgress: false videoToggleInProgress: false
}); });
@@ -11150,7 +11170,7 @@ class CallPanel extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCompon
render() { render() {
const audioTracks = this.state.localStream && this.state.localStream.getAudioTracks(); const audioTracks = this.state.localStream && this.state.localStream.getAudioTracks();
const videoTracks = !this.state.audioOnly && this.state.localStream && this.state.localStream.getVideoTracks(); const videoTracks = !this.state.audioOnly && this.state.localStream && this.state.localStream.getVideoTracks();
const disabled = !(audioTracks && audioTracks[0]); const disabled = !this.state.pc || !this.state.dataChannel || !(audioTracks && audioTracks[0]);
const audioIcon = audioTracks && audioTracks[0] && audioTracks[0].enabled ? 'mic' : 'mic_off'; const audioIcon = audioTracks && audioTracks[0] && audioTracks[0].enabled ? 'mic' : 'mic_off';
const videoIcon = videoTracks && videoTracks[0] && videoTracks[0].enabled && videoTracks[0].readyState == 'live' ? 'videocam' : 'videocam_off'; const videoIcon = videoTracks && videoTracks[0] && videoTracks[0].enabled && videoTracks[0].readyState == 'live' ? 'videocam' : 'videocam_off';
const peerTitle = (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_5__.clipStr)(this.props.title, _config_js__WEBPACK_IMPORTED_MODULE_3__.MAX_PEER_TITLE_LENGTH); const peerTitle = (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_5__.clipStr)(this.props.title, _config_js__WEBPACK_IMPORTED_MODULE_3__.MAX_PEER_TITLE_LENGTH);
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+41 -20
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long