mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-14 20:29:19 +00:00
Performance: Use a shared timer for polling RTP stats
This is now only relevant in case the user has enabled the developer option to show advanced media statistics, but still an easy performance fix.
This commit is contained in:
@@ -19,10 +19,15 @@ import {
|
||||
startWith,
|
||||
switchMap,
|
||||
map,
|
||||
share,
|
||||
} from "rxjs";
|
||||
|
||||
import { observeTrackReference$ } from "../observeTrackReference";
|
||||
|
||||
// Use a shared timer for all the stats observers so that we don't clog up the
|
||||
// event loop with hundreds of timers in large calls
|
||||
const refreshStats$ = interval(1000).pipe(share());
|
||||
|
||||
export function observeRtpStreamStats$(
|
||||
participant: Participant,
|
||||
source: Track.Source,
|
||||
@@ -32,7 +37,7 @@ export function observeRtpStreamStats$(
|
||||
> {
|
||||
return combineLatest([
|
||||
observeTrackReference$(participant, source),
|
||||
interval(1000).pipe(startWith(0)),
|
||||
refreshStats$.pipe(startWith(0)),
|
||||
]).pipe(
|
||||
switchMap(async ([trackReference]) => {
|
||||
const track = trackReference?.publication?.track;
|
||||
|
||||
Reference in New Issue
Block a user