Skip to content

83a7514

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 17 Nov 17:25

fix(ws): Send audio ahead of video and let it go once stale

Over WebSockets, a congested stretch ended in audio played fast-forward
(#620): every audio frame was kept for a socket however late, behind the
socket's in-order writer and a kernel send buffer that grows to
megabytes, so the stretch's audio arrived after it as one burst, which
the player shed one packet per arrival.

  • A socket's kernel buffer holds at most 64 KiB unsent
    (TCP_NOTSENT_LOWAT); what a slow path backs up waits in the socket's
    outbox, where the writer still decides what goes next. Bytes in flight
    are not bounded by it, and the write backlog the relay and transfers
    read counts both places as before.
  • Audio leaves ahead of whatever else waits in the outbox, in its own
    order, as WebRTC's pacer sends audio ahead of video; a frame already
    being written stays whole.
  • An audio frame still queued 200 ms after it was queued is let go
    unwritten, its sender told it is done: audio that late is worth less
    than the gap it fills. A socket that stops draining is still dropped
    by the liveness rule, as before.

The congestion step on a local build, 20 Mbit/s stepped to 1.5 for 5 s,
two runs each, alternated with main's:

  • the recovery's densest 100 ms: 15 and 31 audio frames (main: 319,
    364), the steady rate being 10;
  • frames the player dropped after the recovery: 7 and 20 (main: 183,
    355);
  • audio while the link is narrow: 90 frames a second (main: 29 to 42).
    It still arrives bunched while the link is narrow, by the shared queue
    of the link itself (#543), and the player's cap drops some of it.
    WebSocket suites (slow page, cut, file transfer, matrix, encoders, ack
    heartbeat) pass against it.