From bb26aa3c2cb8ff961668cf0ad8180d3e9c57f941 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Tue, 21 Oct 2025 23:19:52 +0300 Subject: #4652 Improve switching of webrtc devices --- indra/llwebrtc/llwebrtc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/llwebrtc/llwebrtc.cpp') diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index b9f126e511..699e6b94a8 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -582,6 +582,13 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) deployDevices(); } +void LLWebRTCImpl::setDevices(const std::string& capture_id, const std::string& render_id) +{ + mRecordingDevice = capture_id; + mPlayoutDevice = render_id; + deployDevices(); +} + // updateDevices needs to happen on the worker thread. void LLWebRTCImpl::updateDevices() { -- cgit v1.3 From 0e3ba50520dd4cae89951e62c38b8647f76d9519 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:14:53 +0200 Subject: Revert "Improve switching of webrtc devices" Wrong approach. Might need to split workerDeployDevices into separate recording and rendering variants. This partiall reverts commit bb26aa3c2cb8ff961668cf0ad8180d3e9c57f941, I left log lines. --- indra/llwebrtc/llwebrtc.cpp | 7 ------- indra/llwebrtc/llwebrtc.h | 1 - indra/llwebrtc/llwebrtc_impl.h | 1 - indra/newview/llvoicewebrtc.cpp | 29 +---------------------------- indra/newview/llvoicewebrtc.h | 1 - 5 files changed, 1 insertion(+), 38 deletions(-) (limited to 'indra/llwebrtc/llwebrtc.cpp') diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 699e6b94a8..b9f126e511 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -582,13 +582,6 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) deployDevices(); } -void LLWebRTCImpl::setDevices(const std::string& capture_id, const std::string& render_id) -{ - mRecordingDevice = capture_id; - mPlayoutDevice = render_id; - deployDevices(); -} - // updateDevices needs to happen on the worker thread. void LLWebRTCImpl::updateDevices() { diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index 69dec8b2ce..7d06b7d2b4 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -150,7 +150,6 @@ class LLWebRTCDeviceInterface // set the capture and render devices using the unique identifier for the device virtual void setCaptureDevice(const std::string& id) = 0; virtual void setRenderDevice(const std::string& id) = 0; - virtual void setDevices(const std::string& caprure_id, const std::string& render_id) = 0; // Device observers for device change callbacks. virtual void setDevicesObserver(LLWebRTCDevicesObserver *observer) = 0; diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 5e0885fda1..01cfb17ced 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -443,7 +443,6 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceO void setCaptureDevice(const std::string& id) override; void setRenderDevice(const std::string& id) override; - void setDevices(const std::string& caprure_id, const std::string& render_id) override; void setTuningMode(bool enable) override; float getTuningAudioLevel() override; diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 93f8f0d14a..32f2139679 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -735,8 +735,6 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); LL_DEBUGS("Voice") << "Setting devices to-input: '" << inputDevice << "' output: '" << outputDevice << "'" << LL_ENDL; - bool update_render = false; - bool update_capture = false; // only set the render device if the device list has changed. if (mRenderDevices.size() != render_devices.size() || !std::equal(mRenderDevices.begin(), @@ -750,7 +748,7 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi { addRenderDevice(LLVoiceDevice(device.mDisplayName, device.mID)); } - update_render = true; + setRenderDevice(outputDevice); } // only set the capture device if the device list has changed. @@ -767,22 +765,6 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi addCaptureDevice(LLVoiceDevice(device.mDisplayName, device.mID)); } - update_capture = true; - } - - if (update_render && update_capture) - { - // Do both in one go to avoid multiple deployDevices calls. - // And to avoid situation where workerDeployDevices has an - // obsolete device id - setDevices(inputDevice, outputDevice); - } - else if (update_render) - { - setRenderDevice(outputDevice); - } - else if (update_capture) - { setCaptureDevice(inputDevice); } @@ -816,15 +798,6 @@ void LLWebRTCVoiceClient::setRenderDevice(const std::string& name) } } -void LLWebRTCVoiceClient::setDevices(const std::string& capture_name, const std::string& render_name) -{ - if (mWebRTCDeviceInterface) - { - LL_DEBUGS("Voice") << "new capture device: " << capture_name << " New render device: " << render_name << LL_ENDL; - mWebRTCDeviceInterface->setDevices(capture_name, render_name); - } -} - void LLWebRTCVoiceClient::tuningStart() { if (!mIsInTuningMode) diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 54d8e54ce2..2ce575852a 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -124,7 +124,6 @@ public: void setCaptureDevice(const std::string& name) override; void setRenderDevice(const std::string& name) override; - void setDevices(const std::string& capture_name, const std::string& render_name); LLVoiceDeviceList& getCaptureDevices() override; LLVoiceDeviceList& getRenderDevices() override; -- cgit v1.3 From c6101b38bd7702c9613986ef9eba1d556df050be Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 17 Nov 2025 19:15:23 +0200 Subject: #4948 Crash at webrtc's initializeConnection --- indra/llwebrtc/llwebrtc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/llwebrtc/llwebrtc.cpp') diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index b9f126e511..76ca4abb25 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -914,14 +914,17 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti config.set_max_port(60100); webrtc::PeerConnectionDependencies pc_dependencies(this); - if (mPeerConnectionFactory == nullptr) + // Other thread manages mPeerConnectionFactory's lifetime and it can be reset + // at any momment, create own scoped_refptr (atomic). + webrtc::scoped_refptr peer_connection_factory = mPeerConnectionFactory; + if (peer_connection_factory == nullptr) { RTC_LOG(LS_ERROR) << __FUNCTION__ << "Error creating peer connection, factory doesn't exist"; // Too early? mPendingJobs--; return; } - auto error_or_peer_connection = mPeerConnectionFactory->CreatePeerConnectionOrError(config, std::move(pc_dependencies)); + auto error_or_peer_connection = peer_connection_factory->CreatePeerConnectionOrError(config, std::move(pc_dependencies)); if (error_or_peer_connection.ok()) { mPeerConnection = std::move(error_or_peer_connection.value()); @@ -954,10 +957,10 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti audioOptions.noise_suppression = true; audioOptions.init_recording_on_send = false; - mLocalStream = mPeerConnectionFactory->CreateLocalMediaStream("SLStream"); + mLocalStream = peer_connection_factory->CreateLocalMediaStream("SLStream"); webrtc::scoped_refptr audio_track( - mPeerConnectionFactory->CreateAudioTrack("SLAudio", mPeerConnectionFactory->CreateAudioSource(audioOptions).get())); + peer_connection_factory->CreateAudioTrack("SLAudio", peer_connection_factory->CreateAudioSource(audioOptions).get())); audio_track->set_enabled(false); mLocalStream->AddTrack(audio_track); -- cgit v1.3 From 10201dbbd36d70a6a291c4cb64c1044d99cc46a5 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Fri, 23 Jan 2026 10:54:44 -0800 Subject: Fix failure to reconnect after disconnect and occasional dropout issue (#5322) * Fix failure to reconnect after disconnect and occasional dropout issue We were occasionally seeing dropouts which may have been caused by ICE renegotiate requests. The code is there to reconnect in that case, but there were a few bugs, some of which were likely due to the webrtc upgrade. Also, we were seeing failures to reconnect after voice server restart. There were some issues with the PTT button that came up after the above issue was fixed. * Added a clarification as part of CR * We need to set mute state for p2p/adhoc/group calls as well --- indra/llwebrtc/llwebrtc.cpp | 3 ++- indra/newview/llvoicewebrtc.cpp | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'indra/llwebrtc/llwebrtc.cpp') diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index d1bae49784..8e08239ee6 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -814,6 +814,7 @@ LLWebRTCPeerConnectionImpl::~LLWebRTCPeerConnectionImpl() { mSignalingObserverList.clear(); mDataObserverList.clear(); + mPeerConnectionFactory.release(); if (mPendingJobs > 0) { RTC_LOG(LS_ERROR) << __FUNCTION__ << "Destroying a connection that has " << std::to_string(mPendingJobs) << " unfinished jobs that might cause workers to crash"; @@ -877,7 +878,6 @@ void LLWebRTCPeerConnectionImpl::terminate() } mPendingJobs--; }); - mPeerConnectionFactory.release(); } void LLWebRTCPeerConnectionImpl::setSignalingObserver(LLWebRTCSignalingObserver *observer) { mSignalingObserverList.emplace_back(observer); } @@ -1004,6 +1004,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti } webrtc::PeerConnectionInterface::RTCOfferAnswerOptions offerOptions; + this->AddRef(); // CreateOffer will deref this when it's done. Without this, the callbacks never get called. mPeerConnection->CreateOffer(this, offerOptions); mPendingJobs--; }); diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 3efcd763e3..80a0e3e5c0 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2549,10 +2549,7 @@ void LLVoiceWebRTCConnection::OnRenegotiationNeeded() LL::WorkQueue::postMaybe(mMainQueue, [=, this] { LL_DEBUGS("Voice") << "Voice channel requires renegotiation." << LL_ENDL; - if (!mShutDown) - { - setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); - } + setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); mCurrentStatus = LLVoiceClientStatusObserver::ERROR_UNKNOWN; }); } @@ -2898,9 +2895,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() // this connection. // For spatial this connection will come up as muted, but will be set to the appropriate // value later on when we determine the regions we connect to. - if (!isSpatial()) + if (isSpatial()) { - mWebRTCAudioInterface->setMute(mMuted); + // we'll determine primary state later and set mute accordinly + mPrimary = false; } mWebRTCAudioInterface->setReceiveVolume(mSpeakerVolume); LLWebRTCVoiceClient::getInstance()->OnConnectionEstablished(mChannelID, mRegionID); @@ -2924,6 +2922,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() LLWebRTCVoiceClient::getInstance()->updatePosition(); LLWebRTCVoiceClient::getInstance()->sendPositionUpdate(true); } + else + { + mWebRTCAudioInterface->setMute(mMuted); + } } break; } -- cgit v1.3