"The call was bad" is the most common WebRTC bug report and the least useful. Bad could mean frozen video, robotic audio, a blurry picture, echo, or a ten-second gap after someone joined. Each has a different cause, and the browser already measures almost everything you need to tell them apart. The trick is knowing where to look and which numbers matter.
This guide covers two tools: Chrome's built-in chrome://webrtc-internals page for live debugging and dumps, and the standard getStats() API for collecting the same data from real users. By the end you should be able to take a vague complaint and answer "what broke, on which side, and why".
chrome://webrtc-internals in five minutes
Open chrome://webrtc-internals in a new tab before starting the call, then start the call in another tab. The page shows:
getUserMedia requests: each capture request with its constraints and result. Useful when a camera opens at the wrong resolution or fails.
One section per
RTCPeerConnection: the configuration it was created with (ICE servers, bundle policy), and an event log of every API call and state change:createOffer,setLocalDescription,icecandidate,iceconnectionstatechangeand so on.Stats tables and graphs: every stats object the connection reports, refreshed every second, with a graph per numeric field.
The event log answers setup questions. If the call never connected, read it top to bottom: did both descriptions get applied, were candidates gathered, did any candidate pair succeed? If the call connected but quality was bad, skip to the stats graphs.
Taking a dump
The dump section at the top of the page downloads the peer connection updates and stats history as a JSON file. Ask testers or support agents to do this right after a bad call while the tab is still open; once the connection object is gone, so is the history. The dump contains IP addresses from ICE candidates, so treat it as personal data.
Other browsers have equivalents: Firefox has about:webrtc with connection logs and stats, and Safari exposes WebRTC logging through its Develop menu and Web Inspector. The stats objects themselves come from the same W3C specification, so the names below work across browsers, although not every browser fills in every field.
The stats model
getStats() returns a map of stats objects, each with a type. For quality debugging you need about six types:
Type | What it describes | Where to look for |
|---|---|---|
| What you send, per stream | Encoder limits, resolution, bitrate |
| What the other side says it received from you | Loss and round-trip time on your upload |
| What you receive, per stream | Jitter, loss, decoded and dropped frames, freezes |
| What the other side says it sent | Comparing sent versus received |
| The network path in use | RTT, available bandwidth, relay or direct |
| The captured track | Capture resolution and frame rate |
Most counters are cumulative since the stream started. A packetsLost value of 500 means nothing alone; 500 over a 30-minute call is fine, 500 in the last ten seconds is not. Always compute deltas between samples.
The metrics that explain most complaints
Choppy or robotic audio
On the receiver's inbound-rtp for audio:
packetsLostandpacketsReceived: compute loss rate per interval. Above about 5 percent, speech starts to break up even with concealment.jitter(in seconds): variation in packet arrival time. Rising jitter makes the jitter buffer grow, which adds delay, or underrun, which causes gaps.concealedSamplesandtotalSamplesReceived: how much audio the decoder had to invent to cover missing packets. The ratio is a direct "how robotic was it" number.jitterBufferDelaydivided byjitterBufferEmittedCount: average time audio spent in the buffer. A steadily growing value means latency is building up.
Frozen or stuttering video
On the receiver's inbound-rtp for video:
framesReceived,framesDecoded,framesDropped: if frames arrive but are not decoded, look at the decoder; if they are decoded but dropped, the receiving device cannot keep up.framesPerSecond: the decoded frame rate right now.freezeCountandtotalFreezesDuration: the browser's own count of visible freezes. This is the closest metric to what the user actually saw.nackCount,pliCount,firCount: how often the receiver asked for retransmission or a new keyframe. Many PLIs usually mean heavy loss or a decoder that keeps failing.
Blurry or low-resolution video
On the sender's outbound-rtp:
qualityLimitationReason: one ofnone,cpu,bandwidthorother. This field tells you why the encoder is not sending the resolution or frame rate it was asked for.qualityLimitationDurations: seconds spent in each limitation state. A call that wascpulimited for 80 percent of its duration points at the sender's device, not the network.frameWidth,frameHeight,framesPerSecond: what the encoder is actually producing, versus whatmedia-sourcesays the camera is capturing.targetBitrateand the delta ofbytesSent: what the congestion controller allows and what it really sends.
Network path
On the active candidate-pair (the one with nominated: true and state: 'succeeded'):
currentRoundTripTime: network RTT in seconds.availableOutgoingBitrate: the bandwidth estimate for your upload.The linked
local-candidaterecord'scandidateType:relaymeans traffic goes through TURN, which adds latency and can be a bottleneck if the relay is far away.
A small collector you can ship
Here is a sampler that runs every five seconds, computes deltas, and produces one compact record per stream. It sends the records with navigator.sendBeacon() so a closing tab still reports.
// webrtc-quality.js
export function startQualitySampler(pc, { intervalMs = 5000, endpoint = '/api/call-quality' } = {}) {
let prev = new Map();
async function sample() {
if (pc.connectionState === 'closed') return stop();
const report = await pc.getStats();
const rows = [];
report.forEach((s) => {
const before = prev.get(s.id);
if (s.type === 'inbound-rtp' && before) {
const recv = s.packetsReceived - before.packetsReceived;
const lost = s.packetsLost - before.packetsLost;
rows.push({
dir: 'in', kind: s.kind,
lossPct: recv + lost > 0 ? (100 * lost) / (recv + lost) : 0,
jitterMs: Math.round((s.jitter ?? 0) * 1000),
fps: s.framesPerSecond ?? null,
droppedFrames: (s.framesDropped ?? 0) - (before.framesDropped ?? 0),
freezes: (s.freezeCount ?? 0) - (before.freezeCount ?? 0),
});
}
if (s.type === 'outbound-rtp' && s.kind === 'video' && before) {
rows.push({
dir: 'out', kind: 'video',
kbps: Math.round(((s.bytesSent - before.bytesSent) * 8) / intervalMs),
width: s.frameWidth, height: s.frameHeight,
limit: s.qualityLimitationReason,
});
}
if (s.type === 'candidate-pair' && s.nominated && s.state === 'succeeded') {
const local = report.get(s.localCandidateId);
rows.push({
dir: 'net',
rttMs: Math.round((s.currentRoundTripTime ?? 0) * 1000),
relay: local?.candidateType === 'relay',
});
}
});
prev = new Map([...report].map(([id, s]) => [id, s]));
if (rows.length) {
navigator.sendBeacon(endpoint, JSON.stringify({ t: Date.now(), rows }));
}
}
const timer = setInterval(sample, intervalMs);
function stop() { clearInterval(timer); }
return stop;
}
Call startQualitySampler(pc) once the connection is established and call the returned stop() when you tear the call down. Five seconds is a good default: often enough to see spikes, cheap enough not to show up in performance profiles.
Reading a bad call: a worked example
A user reported "video kept freezing for about a minute in the middle". Their records showed:
Time | in video fps | freezes | lossPct | out limit | rttMs | relay |
|---|---|---|---|---|---|---|
12:04:10 | 28 | 0 | 0.2 | none | 45 | false |
12:04:15 | 9 | 2 | 14.0 | bandwidth | 310 | false |
12:04:20 | 4 | 3 | 22.5 | bandwidth | 480 | false |
12:05:10 | 26 | 0 | 0.4 | none | 50 | false |
Loss and RTT rose together on both directions while the encoder reported bandwidth limitation. That is a network event on the user's side, not a decoder or CPU problem, and the call recovered on its own. A different user with limit: cpu most of the call and normal loss would need a different answer: lower the send resolution on that device class.
Common mistakes
Mistake | Why it hurts | Do this instead |
|---|---|---|
Logging raw cumulative counters | Long calls look terrible, short ones look fine | Compute deltas per interval |
Only collecting from the sender | Half the story; receivers see the freezes | Sample both sides and join by call id |
Polling every 100 ms | Costs CPU on the devices you are trying to diagnose | 2-10 second intervals |
Relying on deprecated callback | Removed from browsers; fields differ | Use the promise-based standard API |
Storing full dumps forever | Dumps include IP addresses | Keep summaries, expire raw dumps quickly |
Key takeaways
Use
chrome://webrtc-internalsfor live debugging and ask for a dump right after a bad call.Pick the stats type by symptom:
inbound-rtpfor what users saw,outbound-rtpfor why the sender reduced quality,candidate-pairfor the network.qualityLimitationReasonseparates CPU problems from network problems in one field.freezeCountandconcealedSamplesare the closest numbers to user experience.Always compute deltas and collect from both ends of the call.
References
W3C, Identifiers for WebRTC's Statistics API: https://www.w3.org/TR/webrtc-stats/
MDN,
RTCPeerConnection.getStats(): https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStatsMDN,
RTCInboundRtpStreamStats: https://developer.mozilla.org/en-US/docs/Web/API/RTCInboundRtpStreamStatsMDN,
RTCOutboundRtpStreamStats: https://developer.mozilla.org/en-US/docs/Web/API/RTCOutboundRtpStreamStatsMDN,
Navigator.sendBeacon(): https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
Comments
0No comments yet. Be the first to comment!
Sign In to post a comment.