Skip to content

Commit cce9e58

Browse files
committed
try fix null ref exception in tests
1 parent 0ce9e16 commit cce9e58

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Packages/StreamVideo/Runtime/Core/LowLevelClient/RtcSession.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ public async Task StopAsync(string reason = "")
393393
{
394394
// Trace leave call before leaving the call. Otherwise, stats are not send because SFU WS disconnects
395395
_sfuTracer?.Trace(PeerConnectionTraceKey.LeaveCall, new { SessionId = SessionId, Reason = reason });
396-
await _statsSender.SendFinalStatsAsync();
396+
if (_statsSender != null) // This was null in tests
397+
{
398+
await _statsSender.SendFinalStatsAsync();
399+
}
397400
}
398401
catch (Exception e)
399402
{

Packages/StreamVideo/Runtime/Core/Stats/WebRtcStatsSender.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ internal WebRtcStatsSender(RtcSession rtcSession, IWebRtcStatsCollector webRtcSt
7676

7777
private async Task CollectAndSend()
7878
{
79+
if (_rtcSession.ActiveCall == null)
80+
{
81+
return;
82+
}
83+
7984
var subscriberStatsJson = await _webRtcStatsCollector.GetSubscriberStatsJsonAsync();
8085
var publisherStatsJson = await _webRtcStatsCollector.GetPublisherStatsJsonAsync();
8186
var rtcStatsJson = await _webRtcStatsCollector.GetRtcStatsJsonAsync();

0 commit comments

Comments
 (0)