Skip to content

conference: an unreliable fast lane for pose snapshots (WebRTC data channels) - #949

Merged
transfix merged 2 commits into
feat/conf-pose-snapshots-v2from
feat/conf-unreliable-transport
Nov 1, 2026
Merged

transfix merged 2 commits into
feat/conf-pose-snapshots-v2from
feat/conf-unreliable-transport

Conversation

@transfix

@transfix transfix commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

The conference's pose snapshots can now travel an unreliable, unordered transport beside each client's reliable connection, QuakeWorld-style: a lost packet is superseded by the next, and nothing waits behind it. The room tree (roster, scene, intents, chat) stays on gRPC / WebSocket as it is.

Stacked on #951 (feat/conf-pose-snapshots-v2, the PoseSnapshot stream rebased onto master after #945), so this diff is only the lane. It gets retargeted to master when #951 lands, and merges on full green CI. libcvc's build and format checks only run on PRs into master.

Design and measurements: docs/roadmap/CONFERENCE_UNRELIABLE_TRANSPORT.md.

What it is

  • Two WebRTC data channels per client, each its own peer connection to the relay, both unordered:

    • a pose lane (maxRetransmits 0) for pose snapshots and their acks;
    • a media lane (lifetime 100 ms) for camera and mic frames, off by default (arisrv --lane-media on).

    Separate associations keep the poses out of the video's SCTP congestion window. On one association, under 3 % loss, the poses queued behind the video at the sender (doc §7).

  • Libraries: libdatachannel natively, datachannel-wasm in the browser. Both are cvcpkg recipes: recipes: libdatachannel 0.24.6 and datachannel-wasm 0.4.0 (WebRTC data channels) cy-pca/cvcpkg#539.

  • CVC_ENABLE_RTC (default OFF). Without it the lane classes are inert stubs, so callers need no #if, and every client stays on its reliable connection.

  • Relay.

    • One UDP port for every lane (ICE UDP mux), host candidates only, no STUN or TURN.
    • arisrv --lane-listen 0.0.0.0:7703 [--lane-advertise <public ip>]. Off by default.
  • Signaling.

    • The offer is a state_message with ttl 0 at the participant's own path (<participant>.lane.<pose|media>). A relay now delivers ttl-0 messages to its own shards only and forwards them nowhere.
    • The answer goes through the new state_transport::send_message_to(pid, msg), to that participant's connections alone, and also through the admission hold.
    • Bound writes already restrict that path to the participant's own connection. A lane's media is refused if it claims another origin.
  • Poses: the PoseSnapshot stream, acked.

    • The lane's pose datagram is the kind byte plus the serialized PoseSnapshot (Frame field 13's message).
    • room_pose_relay::set_lane: a viewer whose pose lane is open gets its snapshots there. Same area of interest, same 60/30/20 Hz rate (fed the lane's RTT), same 2 s keyframe. Opening or closing the lane restarts the stream with a keyframe on the new path.
    • pose_stream_encoder::set_acked: on the lane nothing commits on write. Each snapshot gets its own seq and its state is kept (64) until the viewer acks one. That one becomes the base, so a lost snapshot is carried by the next. Commit-on-write is unchanged on the reliable path.
    • pose_stream_decoder::set_bases(32): the client keeps the last 32 decoded states by seq, applies a snapshot against the base it names (a missing base is a gap, as before), and acks it. An older tick still becomes a base but gives no samples. A keyframe keeps the bases, because until its ack every snapshot is base 0 and the relay may take any of their acks.
    • The client applies the samples with apply_pose_samples (new in holon_sync, called by apply_pose_snapshot too).
  • The relay stays the hub for media.

    • The media lanes' server is a media_endpoint, so the area-of-interest gate and the per-viewer rung shaper apply to it unchanged.
    • The reliable endpoints drop media for a viewer whose media lane is open.
    • The rung controller reads the lane's link report first.
  • Liveness.

    • The relay closes a lane silent for 3 s, so its viewer falls back to the connection at once.
    • arigl re-offers a lane that went silent or closed.
  • Clients.

    • arigl offers lanes with CVC_ARIADNE_LANE=1; cyprty with ?lane=1.
    • arisrv_aoi_bench --lane rtc runs the same (it needs --poses stream).
    • The bench also measures, on one clock: pose arrival, pose age at each client frame, media trip time and media delivery.

Measured

catx-03, unprivileged netns with netem on loopback; 2 clients, 60 Hz snapshots and client frames, 15 fps 5.4 KB camera + Opus mic, 30 s.

Over 3 runs of each lossy row (ms; a range where runs differ):

path WebSocket gRPC pose lane + WebSocket pose lane + gRPC
pose arrival p99, 1 % loss 71–74 74–76 21 22
pose arrival p99, 3 % ± 5 ms 94–133 90–98 25 25
pose arrival p99, bursty (Gilbert-Elliott ~3 %) 93–139 314–7792 21 22
pose age p99, 1 % loss 84 84 51–52 51
pose age p99, 3 % ± 5 ms 102–141 101–102 52–54 52–62
pose age p99, bursty 101–668 585–7789 52 52–53
  • gRPC can stall for seconds under bursty loss, whatever carries the poses. Snapshots on gRPC stalled in 4 of 9 runs and tree poses in 4 of 6, across 60 Hz and 30 Hz clients (Conference: avatar poses as compact per-viewer snapshots at up to 60 Hz #951's reruns plus these), so it predates both PRs. gRPC queues every write, and the media stall drop never fired in any of the 15 runs (stalled 0). With poses on the lane, gRPC carried the media without a stall in 3 of 3 runs, but at these odds that is only a hint. Doc §7.4 item 3.
  • The lane's counters: 0 gaps in every run. It costs about 13 kb/s per viewer here. Peers are drawn 75–77 ms behind the server at p50, against 79–111 ms over TCP under loss.
  • A keyframe must keep the decoder's bases. The first cut cleared them on every base-0 snapshot. That cost about 68 gaps per run, and a stall until the next keyframe whenever the newest keyframe's ack was lost (pose age p99 up to 814 ms). Fixed, with a test.

Reconcile corrections (probes.correction_sum_m, m over 30 s, each run):

  • pose lane + gRPC: 3.0, 2.8, 2.6 / 3.1, 3.1, 3.3 / 3.5, 2.9, 3.2, the same as gRPC (2.6–5.6 when it did not stall).
  • pose lane + WebSocket: 6.0, 4.8, 6.3 / 8.6, 5.1, 5.1 / 4.9, 5.8, 5.2. That is 1.5–2 m above WebSocket alone (2.7–5.8, and one 10.0).

The intents still ride the reliable connection, stamped against the lane's quicker server ticks. That is my guess for the WebSocket gap, and it is not yet measured. Intents on the lane are the next step (doc §9).

  • Media stays on the connection by default. In the first spike the media lane was later at the tail than TCP under loss (camera p95 121–210 against 84–132 ms) and delivered 92–99 %, because of usrsctp's RFC 2581 congestion control (doc §5, §7.3).

Tests

  • fast_lane_test, 13 cases:

    • the codecs (media, probes, ack, the PoseSnapshot datagram);
    • the acked stream: a lost snapshot superseded, a change resent until acked, an unknown base as a gap until the keyframe, a keyframe keeping the bases its acks may name, a new encoder forgetting them, the reliable rules unchanged;
    • room_pose_relay onto a lane and back (a third of the snapshots lost, within 1 mm of the server, keyframes on each switch);
    • real lanes on loopback (open, both directions, pings, gate, origin check, idle close, two servers on one port).

    Passes 13/13 on Windows (MSVC) and Linux (catx-03, gcc 11). pose_stream_test 9/9 and holon_sync_test 17/17 on both.

  • Regression suites on Windows: state_transport_ws 40, state_transport_grpc 46, room_aoi 14, room_aoi_relay 10, room_relay_integration 16, room_media 2.

  • The stub path (no CVC_ENABLE_RTC) compiles. CI builds it.

  • cyprty (wasm, CVC_ENABLE_RTC=ON) builds against the datachannel-wasm recipe. The browser run in doc §7.5 is from before the PoseSnapshot rework. That session had both lanes open against a local arisrv, with media in and acks back. It needed the recipe's heap-views.patch. One session of three hit an uncaught Asyncify exception, so the lane is opt-in until that is reproduced.

Not in this PR

  • Deploying the lane. It needs a UDP port forward to paladin and a relay restart with --lane-listen, so it waits for a go-ahead.
  • Making the lane the client default.
  • Intents on the lane (the next latency-critical stream, doc §9).
  • libcvc's own cvcpkg recipe does not list libdatachannel yet (CVC_ENABLE_RTC is off there).

@transfix
transfix force-pushed the feat/conf-unreliable-transport branch from 3b4a6cd to 43d5913 Compare November 1, 2026 00:59
@transfix transfix changed the title Conference: a fast lane for poses on unreliable WebRTC data channels (design, measurements, spike) conference: an unreliable fast lane for pose snapshots (WebRTC data channels) Nov 1, 2026
@transfix
transfix changed the base branch from master to feat/conf-pose-snapshots November 1, 2026 00:59
…hannels)

Each client may open WebRTC data channels to the relay beside its reliable
connection, unordered and never waited for: a pose lane (maxRetransmits 0)
and, with arisrv --lane-media on, a media lane (lifetime 100 ms). Each is its
own peer connection on the relay's one UDP port (ICE UDP mux, host
candidates, no STUN/TURN), so poses never queue behind video in one SCTP
congestion window. The room tree stays on gRPC/WebSocket.

The pose lane carries room_pose_relay's PoseSnapshot stream. On the lane the
encoder runs acked (pose_stream_encoder::set_acked): nothing commits on
write, every snapshot differs from the last one the viewer acknowledged, so a
lost one is superseded by the next. The client decodes with 32 kept bases
(pose_stream_decoder::set_bases), acks what it decodes, and applies the
samples with apply_pose_samples. A keyframe keeps the bases: until its ack,
every snapshot is base 0 and any of their acks may become the base. The rate
(60/30/20 Hz, fed the lane's RTT), the area of interest and the 2 s keyframe
are unchanged; opening or closing a lane restarts the stream on the new path.

- cvc::net: fast_lane (datagram envelope, codecs, hub) and fast_lane_rtc
  (libdatachannel natively, datachannel-wasm in the browser), behind
  CVC_ENABLE_RTC (default OFF; inert stubs without it).
- Signaling: a ttl-0 state_message at <participant>.lane.<pose|media>,
  never forwarded; the answer goes through the new
  state_transport::send_message_to, written through the admission hold.
- The media lane server is a media_endpoint (AOI gate, rung shaper); the
  reliable endpoints send a lane viewer no media; lane link reports first.
- arisrv --lane-listen/--lane-advertise/--lane-media; arigl
  CVC_ARIADNE_LANE=1; cyprty ?lane=1; arisrv_aoi_bench --lane rtc with
  pose-arrival, pose-age, media and correction probes.

Measured on catx-03 (netns + netem, 2 clients, 60 Hz snapshots, camera +
mic, 3 runs per lossy row): pose arrival p99 21-25 ms on the lane against
71-139 ms over WebSocket and 74-98 ms over gRPC at random loss; pose age p99
51-62 ms against 84-141 ms. Under bursty loss gRPC can stall for seconds
whatever carries the poses (it queues every write). Media stays on the
connection by default: usrsctp's congestion control was slower than TCP's
under loss.
Design and tables: docs/roadmap/CONFERENCE_UNRELIABLE_TRANSPORT.md.
…des and at both client rates

The snapshot session's corrected reruns (#951): tree poses stalled 3 of 3 at 60 Hz client frames and 1 of 3 at 30 Hz; snapshots 0 of 3 and 2 of 3. Neither the snapshots nor the 60 Hz client rate cause it, and the media stall drop never fired in any of the 15 runs.
@transfix
transfix force-pushed the feat/conf-unreliable-transport branch from 43d5913 to 2b1a340 Compare November 1, 2026 03:24
@transfix
transfix changed the base branch from feat/conf-pose-snapshots to feat/conf-pose-snapshots-v2 November 1, 2026 03:24
@transfix
transfix merged commit 8847ee6 into feat/conf-pose-snapshots-v2 Nov 1, 2026
1 of 2 checks passed
@transfix
transfix deleted the feat/conf-unreliable-transport branch November 1, 2026 03:35
transfix added a commit that referenced this pull request Nov 2, 2026
…Hz (#951)

* Conference: avatar poses as compact per-viewer snapshots at up to 60 Hz

Poses used to replicate as room-tree leaves:
- about 110 bytes for each changed number, roughly 780 bytes per walking avatar per update, sent
  as 7 separate messages;
- at the relay's 20 Hz step;
- to every client alike.

Each viewer now gets its own stream:
- The relay steps the room at 60 Hz. room_pose_relay sends each viewer that is due one
  PoseSnapshot frame (a new Frame kind on both transports) with the participants it sees.
- Positions go in mm, velocities in mm/s, and quaternions as components times 32767.
- Each value is the difference from what that connection was last sent (pose_stream.h): a
  walking avatar costs about a dozen bytes, and a still one a two-byte heartbeat a second.
- A viewer's rate follows its round trip from the link reports: 60 Hz under 80 ms, 30 Hz under
  160 ms, 20 Hz beyond, with 10% hysteresis.
- Middle and outer AOI pairs keep the push cadence.
- Every 2 s a viewer's stream restarts with absolute entries, so a client that lost its place
  (a snapshot written into a dying connection) is back in step.
- Snapshots are link-level like media: never journaled, relayed or bridged. A WebSocket peer
  backed up past 64 KB skips one, and the next carries the difference.
- The tree's copy of the poses drops to 1 Hz, for late joiners and the log.

Clients (arigl, and the bench) apply snapshots through apply_pose_snapshot before client_pump.
The holon's playout learns the shorter interval; its assumed interval before measuring is now 2
ticks.

arisrv_aoi_bench gains --poses tree|stream, --client-hz, a per-receiver snapshot byte count and
a peer-lag probe. On loopback with clients at 60 fps:
- 2 clients: 168 kb/s into each client and 70/87 ms peer lag (p50/p95) become 47 kb/s and
  48/62 ms.
- 6 clients, gRPC and WebSocket mixed: 400-431 kb/s and 103/130 ms become 92-122 kb/s and
  42/60 ms.
- The relay's output drops from 2.5 to 0.66 Mb/s, and its room step from 4.9 ms to 0.6 ms (p50).

* conference: an unreliable fast lane for pose snapshots (WebRTC data channels) (#949)

* conference: an unreliable fast lane for pose snapshots (WebRTC data channels)

Each client may open WebRTC data channels to the relay beside its reliable
connection, unordered and never waited for: a pose lane (maxRetransmits 0)
and, with arisrv --lane-media on, a media lane (lifetime 100 ms). Each is its
own peer connection on the relay's one UDP port (ICE UDP mux, host
candidates, no STUN/TURN), so poses never queue behind video in one SCTP
congestion window. The room tree stays on gRPC/WebSocket.

The pose lane carries room_pose_relay's PoseSnapshot stream. On the lane the
encoder runs acked (pose_stream_encoder::set_acked): nothing commits on
write, every snapshot differs from the last one the viewer acknowledged, so a
lost one is superseded by the next. The client decodes with 32 kept bases
(pose_stream_decoder::set_bases), acks what it decodes, and applies the
samples with apply_pose_samples. A keyframe keeps the bases: until its ack,
every snapshot is base 0 and any of their acks may become the base. The rate
(60/30/20 Hz, fed the lane's RTT), the area of interest and the 2 s keyframe
are unchanged; opening or closing a lane restarts the stream on the new path.

- cvc::net: fast_lane (datagram envelope, codecs, hub) and fast_lane_rtc
  (libdatachannel natively, datachannel-wasm in the browser), behind
  CVC_ENABLE_RTC (default OFF; inert stubs without it).
- Signaling: a ttl-0 state_message at <participant>.lane.<pose|media>,
  never forwarded; the answer goes through the new
  state_transport::send_message_to, written through the admission hold.
- The media lane server is a media_endpoint (AOI gate, rung shaper); the
  reliable endpoints send a lane viewer no media; lane link reports first.
- arisrv --lane-listen/--lane-advertise/--lane-media; arigl
  CVC_ARIADNE_LANE=1; cyprty ?lane=1; arisrv_aoi_bench --lane rtc with
  pose-arrival, pose-age, media and correction probes.

Measured on catx-03 (netns + netem, 2 clients, 60 Hz snapshots, camera +
mic, 3 runs per lossy row): pose arrival p99 21-25 ms on the lane against
71-139 ms over WebSocket and 74-98 ms over gRPC at random loss; pose age p99
51-62 ms against 84-141 ms. Under bursty loss gRPC can stall for seconds
whatever carries the poses (it queues every write). Media stays on the
connection by default: usrsctp's congestion control was slower than TCP's
under loss.
Design and tables: docs/roadmap/CONFERENCE_UNRELIABLE_TRANSPORT.md.

* docs(fast lane): the gRPC bursty-loss stall is random in both pose modes and at both client rates

The snapshot session's corrected reruns (#951): tree poses stalled 3 of 3 at 60 Hz client frames and 1 of 3 at 30 Hz; snapshots 0 of 3 and 2 of 3. Neither the snapshots nor the 60 Hz client rate cause it, and the media stall drop never fired in any of the 15 runs.

* Jolt rollout tests: room for macOS arm64's Jolt runs

On macOS (package-macos release-grpc jobs) the held-out calibration closes the dissipation to
0.152 against a 0.15 bound and its calibrated step's twist is 1% over the uncalibrated one's, and
the gradient check's beta and gamma (a quarter of alpha there) flip sign against Jolt's finite
differences while the gradient as a whole agrees (ratio 0.92). The calibration's margins are 0.2
and 5%; the per-bias checks apply to components at least a third of the largest (all three on
Windows), and the whole-gradient check is unchanged.

* holon_sync_test: the reserve is written on steps that skip the poses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant