diff --git a/.changeset/eighty-snakes-sneeze.md b/.changeset/eighty-snakes-sneeze.md new file mode 100644 index 000000000..65e216d41 --- /dev/null +++ b/.changeset/eighty-snakes-sneeze.md @@ -0,0 +1,5 @@ +--- +"@epicgames-ps/lib-pixelstreamingfrontend-ue5.7": patch +--- + +Add guard against closed `peerConnection` in `generateStats` diff --git a/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts b/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts index e673ac9b8..d4d07fd5e 100644 --- a/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts +++ b/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts @@ -173,9 +173,13 @@ export class PeerConnectionController { generateStats() { this.peerConnection?.getStats().then((statsData: RTCStatsReport) => { this.aggregatedStats.processStats(statsData); - this.onVideoStats(this.aggregatedStats); + // Connection might have been closed in the meantime + if (!this.peerConnection) { + return; + } + // Calculate latency using stats and video receivers and then call the handling function const latencyInfo: LatencyInfo = this.latencyCalculator.calculate( this.aggregatedStats,