v160 · webtransport · getStats() · practical

Adaptive bitrate monitor

The use case the explainer names: a live-media or game client that adapts what it sends to what the network can carry. getStats() is a snapshot, not a stream, so the app polls it. This monitor samples on an interval you choose, plots smoothedRtt against minRtt (the gap is queueing delay) and estimatedSendRate, and picks a video quality tier from the estimate — holding steady, with a stated reason, whenever the estimate is null. Push real bytes through the session to see the estimate move.

Availability. Chrome 160 ships WebTransport.prototype.getStats() enabled by default — the Blink runtime feature WebTransportStats is status: "stable" in runtime_enabled_features.json5. On an older Chrome the method is absent: enable chrome://flags/#enable-experimental-web-platform-features and relaunch, or launch with --enable-blink-features=WebTransportStats (both verified on Chrome 153). Real numbers also need a WebTransport server you can reach: this showcase has no HTTP/3 server of its own, so the default endpoint is a public echo server. If your network blocks QUIC the attempt fails with the real error, shown verbatim — never a made-up result. Running your own server is a few lines; see the local echo server recipe.

Monitor a live session

WebTransport endpoint

Any WebTransport server you can reach — a public echo server by default, or your own local one.

For a local self-signed server (ECDSA, ≤14-day cert). Leave empty for a publicly trusted certificate.

Idle.
smoothedRtt—
minRtt—
queueing (smoothed − min)—
estimatedSendRate—
samples0
bytes echoed0
Last 60 samples. RTT lines share one scale (top = max seen); the send-rate line has its own scale. No samples yet.

Chosen tier

    No decision yet.

    the adaptation rule (in this page)

    code path

    const TIERS = [["240p", 0.4e6], ["480p", 1.2e6], ["720p", 2.5e6], ["1080p", 5e6], ["4K", 16e6]];
    setInterval(async () => {
      const s = await transport.getStats();
      if (s.estimatedSendRate === null) return;             // no estimate: hold
      const budget = s.estimatedSendRate * 0.8;             // bits per second
      let tier = TIERS.findLast(([, bps]) => bps <= budget) ?? TIERS[0];
      if (s.smoothedRtt > 2 * s.minRtt + 20) tier = stepDown(tier);  // queueing
      encoder.configure({ ...config, bitrate: tier[1] });
    }, 500);

    see also