Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webrtc: Warn about changes in stats that should not change #1331

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/stores/omniscientLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ export const useOmniscientLoggerStore = defineStore('omniscient-logger', () => {
'totalFreezesDuration',
'totalPausesDuration',
] // Keys that should not increase
const averageKeysThatShouldNotDecrease: WebRTCVideoStat[] = [
'clockRate',
'framesAssembledFromMultiplePackets',
'framesPerSecond',
'packetRate',
] // Keys that should not decrease
const averageKeysThatShouldNotIncrease: WebRTCVideoStat[] = [
'jitter',
'jitterBufferDelay',
'jitterBufferMinimumDelay',
'jitterBufferTargetDelay',
] // Keys that should not increase

const webrtcStatsAverageLogDelay = 10000
let lastWebrtcStatsAverageLog = new Date()
Expand Down Expand Up @@ -191,6 +203,29 @@ export const useOmniscientLoggerStore = defineStore('omniscient-logger', () => {
}
})

// Warn about changes in average values that should not change
averageKeys.forEach((key) => {
const keyArray = webRtcStatsHistory.value[ev.peerId][key]
if (keyArray.length < historyLength) return

const average = (keyArray as number[]).reduce((a, b) => a + b, 0) / keyArray.length
const currentValue = keyArray[keyArray.length - 1] as number

if (averageKeysThatShouldNotDecrease.includes(key)) {
const minThreshold = 0.9 * average
if (currentValue < minThreshold) {
console.debug(`Drop in the value of key '${key}' for peer '${ev.peerId}': ${currentValue.toFixed(2)}.`)
}
}

if (averageKeysThatShouldNotIncrease.includes(key)) {
const minThreshold = 1.1 * average
if (currentValue > minThreshold) {
console.debug(`Increase in the value of key '${key}' for peer '${ev.peerId}': ${currentValue.toFixed(2)}.`)
}
}
})

// Log the average values recursively
if (new Date().getTime() - lastWebrtcStatsAverageLog.getTime() > webrtcStatsAverageLogDelay) {
averageKeys.forEach((key) => {
Expand Down
Loading