0040: Its own libwebrtc build, without H.264

On this page

Status: accepted; amended the same day: the build moved from this repository to ShortLeash/runtimes, for free runners and the attestations that repository already makes (ADR 0019).

Context

LiveKit publishes prebuilt libwebrtc archives for the webrtc-sys crate. They link FFmpeg (GPL/LGPL, for H.264 decoding) and Cisco's OpenH264 compiled from source, which carries no patent license. Short Leash links no GPL, LGPL or AGPL code (ADR 0014). The crate's build script also downloads the prebuilt without checking it.

Decision

  • The build. Short Leash builds libwebrtc itself, in the public ShortLeash/runtimes repository, as one more of Short Leash's own builds (ADR 0019). Its scripts there are scripts/libwebrtc.sh (macOS) and scripts/libwebrtc-windows.ps1.
    • They use LiveKit's recipe and patches from the webrtc-sys version Short Leash depends on, fetched from crates.io and checked against its SHA-256.
    • The WebRTC source and depot_tools are pinned to commits, not branches.
    • The arguments add rtc_use_h264=false, proprietary_codecs=false and ffmpeg_branding="Chromium".
  • What it contains:
    • AV1 (libaom, dav1d) and VP8/VP9 (libvpx), all BSD and royalty-free.
    • H.265 stays on for macOS: LiveKit's Objective-C codec list needs its classes, and on macOS it's Apple's VideoToolbox.
  • Checks on every build:
    • The output must have no FFmpeg or OpenH264 symbols.
    • Its license list must pass scripts/check-licenses.py.
    • Every component goes into THIRD_PARTY_NOTICES.md.
  • Where it runs. ShortLeash/runtimes' Build workflow builds every target when run with what: libwebrtc: macOS arm64 and x64 on an Apple silicon runner, Windows x64 and arm64 on an x64 runner.
    • It attaches the archives to the release libwebrtc-<webrtc-sys version> with a build attestation.
    • It runs only by hand, when the pinned commit, the crate version or the arguments change.
  • How Short Leash uses it.
    • apps/desktop/scripts/fetch-libwebrtc.sh downloads the archive for a target and checks GitHub's SHA-256 and the attestation: ShortLeash/runtimes' build.yml on main, on a GitHub-hosted runner (invariant 7). It refuses a webrtc-sys version that differs from Cargo.lock.
    • Short Leash's build points webrtc-sys at the result through LK_CUSTOM_WEBRTC (.cargo/config.toml), so the crate never downloads anything itself.
  • Windows builds link the static C runtime (+crt-static) to match.
  • Codec use. Pair only offers AV1 and VP9 (ADR 0035). H.264 through VideoToolbox stalls in this build, and nothing negotiates it.

Consequences

  • Licenses and patents: no copyleft code and no unlicensed H.264 are linked into Short Leash. The 23 remaining licenses are permissive.
  • Same speed: the macOS build ran AV1 and VP9 exactly as fast as the prebuilt in the spikes, and the Rust crates link against it unchanged.
  • Cost: a checkout is about 14 GB and a build an hour or two on hosted runners, which cost nothing in a public repository. Runs are by hand and rare.
  • Upkeep: updating libwebrtc, for security fixes in its decoders, means moving the pin and rebuilding. Pair commits to following LiveKit's releases.
  • Spikes and tests may link LiveKit's prebuilt, checked by SHA-256. What ships never does.