Files
piik/docs/research/browser-screen-audio-quality.md
T
AAA 6cb0ca1a34 fix: repair media startup and retire shared session resources (#483)
Early video retransmissions could be rejected before an SFU publication admitted its primary stream. The shared RTP reader now restores the associated primary identity before admission. A repository audit also found ownership omissions in Viewer input retirement, queued route work, partially constructed connections and sender-evidence cleanup; each is corrected at its existing owner without changing routing or adaptation policy.

The same phase fixes bounded Linux diagnostic encoding, picker/tooltip keyboard and touch behavior, and stale-language notices. Documentation now reflects current App, room and media lifecycles. Theme-role consolidation remains deferred.

Validation: complete Web check (1,685 tests, type-check and build); Windows Go core tests/vet/cross-builds; Linux CI race/vulnerability checks and all seven package targets; native Linux diagnostic fixtures on both architectures; actual Chromium/Pion SFU decode, live settings, reload/recovery and resource-retirement gate; documentation and website builds. Confirmed defects were compared against their baseline and independently reviewed. No protocol, configuration or persistence migration is required. Physical device limits and unmatched field reports remain open.

## Release notes

### 中文

这是一次分享稳定性与交互细节维护更新,兼容现有 2.x 客户端和站点。

- 修复部分服务器中转开播失败:较早到达的视频重传包不再被误判,导致媒体发布提前结束。
- 修复停播后快速重新分享时,旧任务可能拖延新线路准备的问题。
- 撤销邀请或替换观众会话时,同步清理对应的远控输入身份,保留其他观众的正常使用。
- 改善连接失败、观众反复加入退出后的资源回收;避免 Linux 单路输出的错误信息意外中断整个分享。
- 修正选源、互动和线路提示的键盘/触屏操作;切换语言后,当前校验与错误提示会同步更新。

### English

This maintenance update improves sharing reliability and interaction details. It remains compatible with existing 2.x Apps and Sites.

- Fix an SFU startup failure caused by video retransmissions arriving before the primary stream was admitted.
- Prevent retired sharing tasks from delaying route preparation after a quick stop and restart.
- Retire remote-input identities when invitations are revoked or Viewer sessions are replaced, while preserving other participants.
- Release resources correctly after connection failures and repeated Viewer churn; prevent Linux output diagnostics from unexpectedly ending the whole share.
- Improve keyboard and touch behavior in source selection, interactions and route help. Active validation and error messages now follow language changes.
2026-10-19 04:00:40 +08:00

9.6 KiB

Browser Screen-Audio Evidence

  • Reviewed: 2026-08-27
  • Scope: Browser display audio over direct, relay, and LiveKit paths
  • Status: evidence; current controls are owned by media quality

Findings

  • getDisplayMedia() may return no audio track depending on Browser, operating system, selected surface, and user choice. Audio constraints are preferences, not a portable source or fidelity guarantee.
  • Screen audio is distinct from microphone/voice processing. Echo cancellation, noise suppression, gain control, voice isolation, channel count, and content hint requests must be interpreted through actual capture and RTP evidence.
  • One structured sdp-transform operation can request Opus stereo and a receive ceiling while preserving unrelated codecs, media sections, and attributes. Missing or ambiguous Opus targets should leave the Browser answer unchanged.
  • Sender maxBitrate is a ceiling. Fresh parameter readback and interval RTP stats are required; content and congestion may produce lower traffic.
  • Browser relay can keep screen audio in the same persistent MediaStream while source tracks are added, removed, or replaced. It does not need a Web Audio mix/resample graph or second clock.
  • Viewer play, mute, volume, and autoplay recovery remain local under the playback owner and do not change sender or room state.

RED Tradeoff

RTP RED carries redundant prior audio payload to improve short-loss recovery and can materially increase traffic. Under an earlier 64/128/256 kbps experiment, direct and Browser-relay payload tracked the selected sender ceiling, while the then-enabled SFU RED path was approximately double its nominal audio payload.

That measurement justified treating RED and an audio ceiling as separate decisions. Current values and LiveKit options are intentionally not mirrored here; they are owned by the product module and code. Disabling RED does not prove that Opus in-band FEC is enabled or disabled.

Retained Functional Evidence

Chrome 151 controlled runs exercised a direct Host child, a Browser-relay child, and one SFU subscriber with generated screen audio. Video, audio RTP, and decoded audio energy advanced at all tested historical ceilings and after source replacement. The active-audio display also stopped reporting the old constant 1 kbps placeholder.

These runs prove track/sender continuity and stats ownership. They do not prove perceptual music quality, encoded stereo, all capture-source combinations, weak-network behavior, real-game A/V synchronization, or mobile playback.

Open Evidence

  • Chrome/Edge tab, window, and system-audio combinations on supported Windows.
  • Real game/music quality and A/V synchronization over direct, relay, and SFU.
  • Lossy Wi-Fi/cellular concealment and Opus FEC behavior with current options.
  • macOS, Android, and iOS capture/playback behavior.

Numeric Bitrate Assessment

Checked 2026-10-09 for the 2.0 candidate. The published 1.x product retains its preset contract. Candidate numeric requests and supported limits are owned by media quality; these measurements do not establish audible improvement or accept a public release.

For scope review on 2026-10-11, RFC 7587 recommends 64..128 kbps for fullband stereo music with 20 ms frames, and LiveKit's high-quality stereo preset uses 128 kbps. These support retaining the current default; they are neither codec maxima nor proof of quality for every source. Higher custom settings remain subject to the measured packet and receiver bounds below.

The existing Go Opus encoder accepted live 128/192/256/320/96/128 kbps changes without replacement. A 48 kHz stereo tone/noise input continued decoding into 960 samples per channel; the existing deterministic tests also verify stereo separation at 256/320 kbps and rejection of invalid updates without replacing the last setting. This establishes encoding continuity, not audible benefit.

A Chrome 152 loopback used the actual sender primitive, generated stereo audio, and decoded PCM measurement. The same PeerConnections remained connected while changing those ceilings. Received payload tracked approximately 96/128/192/256/320 kbps, with decoded samples advancing and nonzero waveform energy. This is a local Browser check, not relay/SFU, mobile, impaired-network or listening acceptance.

Two controls constrain the replacement design:

  • Chrome retained maxaveragebitrate=192000 in the remote answer and sender codec parameters, yet later setParameters() calls produced approximately 256/320 kbps. Repeating with a 510000 answer also passed. This scoped runtime counterexample does not change RFC 7587's receive-limit semantics. A numeric sender setting must respect the admitted receiver limit; do not assume SDP presence or successful parameter readback proves enforcement.
  • With native 20 ms frames, the tone/noise check produced maximum Opus payloads of 641 bytes at 256 kbps and 801 at 320 kbps. At 510 kbps, all 150 frames produced RTP packets larger than a 1200-byte packetizer budget. Pinned Pion's Opus payloader keeps each Opus payload intact. This is a packet-size result, not measured network loss; accepting the codec's maximum requires a transport/packet-duration decision. Do not equate the codec range with every route's safe operating range.
  • Silence/tone/noise/impulse transitions expose a separate peak: the former gopus v0.1.1 encoder produces a 1234-byte payload at 320 kbps. Its single-stream CELT path also ignores the output budget and fails with a smaller buffer. gopus v0.2.2 honors that budget; the adapter now reserves packet overhead at the encoding boundary using Opus's instantaneous size limit. The retained regression decodes complete 20 ms frames across transients and live bitrate changes. This does not diagnose any field interruption or change the average bitrate controls, stereo format or route model.

The media extension proposal owns the UI and contract rationale. The candidate enforces a Browser sender's negotiated Opus limit, and admits unchanged Native/SFU forwarding only when the receiver's declared limit accommodates the full shared format. A codec-valid native setting beyond the current sender ceiling remains an operational failure. Browser and App preference stores round-trip custom numeric values; those stores were not part of published v1.9.2, so no legacy preset migration is required.

The retained SFU gate passed for both Browser and Windows native publication: live 320/96 kbps changes retained the same subscription, with advancing decoded audio energy and video frames. Video profile changes, reload, recovery and retirement also passed; the Browser run measured stereo separation. An ordinary Browser relay forwarded received tracks to two children at 320 kbps, with advancing decoded audio and successful cleanup. Direct Browser controls keep requested 256/320 kbps below an explicit 192 kbps receive limit, while a 510 kbps receiver permits both rates. The full Browser room also retains both receiving tracks and advancing decoded audio/video through 320/96/320 kbps edits; only the limited child's sender is capped at 192 kbps. Native and SFU adapter controls reject an insufficient answer before binding it. In a full-UI SFU-only room, that rejection exhausts only the limited Viewer's route and retires its connection. The Host, healthy sibling and subsequent capable Viewer continue; the service Debug event retains the receive-limit cause. Stop retires the remaining media. These are controlled SDP-limit checks, not physical low-capability decoder measurements. A native real-Opus control through 6 Mbps -> 500 kbps -> 6 Mbps shaping retains decoded audio during live 320/96/320 kbps changes, with sustained high video after the shared probe measurement and video-budget repairs. These are local runtime checks; physical networks, mobile playback and listening remain open.

RFC 7587 gives an omitted receive bitrate a mode-dependent default, not an unrestricted value, and asks receivers to ignore out-of-range preferences. All candidate Piik receivers therefore declare the full Opus range explicitly, including the App's local preview bridge through the same Browser answer helper. Browser sender enforcement uses libwebrtc's existing default calculation when a peer omits a valid limit. Unchanged forwarding requires an explicit sufficient limit; it cannot turn down the shared source for one receiver.

Primary Sources