Skip to content

Commit be1e9bd

Browse files
authored
Add guard against closed peerConnection (#788)
* Add guard against closed peerConnection * Add changeset
1 parent 1d766d8 commit be1e9bd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/eighty-snakes-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@epicgames-ps/lib-pixelstreamingfrontend-ue5.7": patch
3+
---
4+
5+
Add guard against closed `peerConnection` in `generateStats`

Frontend/library/src/PeerConnectionController/PeerConnectionController.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@ export class PeerConnectionController {
173173
generateStats() {
174174
this.peerConnection?.getStats().then((statsData: RTCStatsReport) => {
175175
this.aggregatedStats.processStats(statsData);
176-
177176
this.onVideoStats(this.aggregatedStats);
178177

178+
// Connection might have been closed in the meantime
179+
if (!this.peerConnection) {
180+
return;
181+
}
182+
179183
// Calculate latency using stats and video receivers and then call the handling function
180184
const latencyInfo: LatencyInfo = this.latencyCalculator.calculate(
181185
this.aggregatedStats,

0 commit comments

Comments
 (0)