Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] Fix lost audio track on safari #11145

Merged
merged 1 commit into from Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/utils/webrtc/simplewebrtc/peer.js
Expand Up @@ -6,6 +6,8 @@ const adapter = require('webrtc-adapter')
const webrtcSupport = require('webrtcsupport')
const WildEmitter = require('wildemitter')

const { isSafari } = require('../../../utils/browserCheck.js')

/**
* @param {object} stream the stream object.
*/
Expand Down Expand Up @@ -833,7 +835,10 @@ Peer.prototype._replaceTrack = async function(newTrack, oldTrack, stream) {
return
}

if (sender.track && newTrack && !newTrack.enabled) {
// When replacing with a null track on Safari the reference to the track is
// lost (setting trackDisabled is not enough). Therefore we keep the track
// intact and don't replace it with a null track.
if (sender.track && newTrack && !newTrack.enabled && !isSafari) {
// Replace with a null track to stop the sender.
newTrack = null
}
Expand Down Expand Up @@ -873,6 +878,8 @@ Peer.prototype.handleSentTrackEnabledChanged = function(track, stream) {
this.handleSentTrackReplacedBound(track, track, stream)
} else if (!track.enabled && sender) {
this.handleSentTrackReplacedBound(track, track, stream)
} else if (!sender && !stoppedSender) {
console.error('No sender found to handle localTrackEnabledChanged', track, stream)
}
}

Expand Down