Skip to content

Conference: phone cameras keep their shape; peers move smoothly - #945

Merged
transfix merged 1 commit into
masterfrom
feat/conf-aspect-peer-motion
Nov 1, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/conf-aspect-peer-motion

Conversation

@transfix

Copy link
Copy Markdown
Owner

Fixes two things reported on the live conference.

Phone cameras keep their shape

In the browser, a phone camera looked squashed, both to its owner and to every peer.

Cause. SDL 3.4's browser camera draws each frame into a canvas fixed at the size the track
reported at open, then stretches it to the size the app asked for (320x240). A portrait phone,
or one turned mid-call, came out stretched.

Fix.

  • Own browser capture (camera_source.cpp). The single-threaded page now captures the camera
    itself:

    • it reads a <video> on getUserMedia with no size constraint, so the browser cannot crop it;
    • each frame is drawn at the video's current size, which follows rotation, and the canvas scales
      it to the budget.

    A threaded build keeps SDL but asks it for no size.

  • Budget turns with the frame (stream::fit_frame). A portrait phone in 320x240 sends 240x320
    (180x320 at 9:16), and the JPEG carries that shape to every rung.

  • stream_view takes size: [w, h]. The frame is fitted inside the box with its shape kept
    (Backend::draw_image_fit), and ImGui fills the spare space with black bars. The conference
    tiles use boxes now, so a portrait camera shows whole without growing its window.

Peers move smoothly

A peer's avatar moved smoothly on their own screen but stuttered for everyone else.

Cause. The client walked each peer from where it was shown to the newest sample, timed by when
that sample arrived. Every late sample stopped the peer, and every early one rushed it.

Fix (holon::display_pose).

  • Playout from a buffer. Each peer's samples are buffered, and the peer is shown on a wall-time
    timeline a delay behind its newest sample: one interval plus a margin for the measured arrival
    jitter, followed through a lag.
  • Between samples, the position follows a cubic Hermite through both positions and velocities
    (a straight line when the velocities don't fit).
  • Past the newest sample, the peer carries on along its velocity for up to 200 ms.
  • Changes of course ease out over 100 ms; a teleport is shown at once.
  • Clock independence. The client clock's re-alignments and slews no longer move peers.

Relay (arisrv, WS transport).

  • The relay steps the room on a fixed 50 ms grid and sends each step's poses as soon as they are
    made.
  • The WebSocket sockets set TCP_NODELAY. Before, a delayed ACK could hold a small pose write back.

Measured

HolonTest.APeerMovesSmoothlyThroughJitterAndLoss walks a peer around a 4 m circle at 3 m/s.
Samples come every 6 ticks, arrive up to 40 ms late, 5% are lost, and the client runs at 60 fps.
The same scenario was replayed through the old walk-from-arrival model:

stalled frames frames off speed (±25%) RMS acceleration
old walk 96 / 599 286 / 599 107 m/s²
playout buffer 0 0 2.33 m/s² (the walk's own: 2.25)

Tests

All run locally (Windows, static WS+gRPC tree and the shared cvcGL tree):

  • Holon: holon_test (31) passes, including the new smoothness, fixed-delay and teleport cases;
    the peer cases that encoded the old walk are rewritten. holon_sync_test (17), avatar_sim_test
    (8) and room_aoi_test (14) also pass.

  • Transports and relay: room_relay_integration_test (16), state_transport_ws_test (39) and
    room_intrinsics_test (15) pass.

  • Media: media_rungs_test passes, with a portrait frame keeping its shape on every rung.

  • Stream view: ariadne_stream_view_test passes fit_frame and the size parsing. Its terminal
    box case is skipped here (no FTXUI in these trees), so CI is the first run of that case.

  • cvcGL: cvcgl_media_capture passes; a portrait capture in the 320x240 MJPEG stream decodes as
    180x320.

  • Browser camera:

    • camera_source.cpp compiles with emcc using the wasm tree's flags;
    • its JS parses in strict mode and passes a node run against a mocked camera (portrait size, a
      rotation, no double reads, track stopped on close).

    It has not run on a phone yet.

  • arisrv: smoke-ran at its 120 Hz pace.

Phone cameras keep their aspect ratio:
- In the browser, a phone camera was squashed, for its owner and for every peer. SDL 3.4's
  browser camera draws each frame into a canvas fixed at the size the track reported when it
  opened, then stretches it to the size the app asked for (320x240). A portrait phone, or one
  turned mid-call, came out stretched.
- The single-threaded page now captures the camera itself. It reads a <video> on getUserMedia
  with no size constraint, so the browser cannot crop it. Each frame is drawn at the video's
  current size, which follows rotation, and the canvas scales it to the budget.
- A threaded build keeps SDL but asks it for no size.
- The budget turns with the frame (stream::fit_frame): a portrait phone in 320x240 sends
  240x320 (180x320 at 9:16), and the JPEG carries that shape to every rung.
- stream_view takes `size: [w, h]`, a box the frame is fitted into with its shape kept
  (Backend::draw_image_fit). ImGui fills the spare space with black bars. The conference tiles
  are boxes now, so a portrait camera shows whole without growing its window.

Peer avatars move smoothly:
- Peers moved smoothly for their own user but stuttered for everyone else. The client walked
  each peer from where it was shown to the newest sample, timed by when that sample arrived,
  so every late sample stopped the peer and every early one rushed it.
- Each peer now plays out from a buffer of its samples. It is shown on a wall-time timeline a
  delay behind its newest sample: one interval plus a margin for the measured arrival jitter,
  followed through a lag.
- Between samples, position follows a cubic Hermite through both positions and velocities
  (straight when the velocities don't fit). When the buffer runs dry, the peer carries on
  along its velocity for up to 200 ms.
- A change of course eases out over 100 ms; a teleport is shown at once.
- The client clock's re-alignments and slews no longer move peers.
- The relay steps the room on a fixed 50 ms grid, sends each step's poses as soon as they are
  made, and sets TCP_NODELAY on WebSocket sockets. A delayed ACK held small pose writes back.

HolonTest.APeerMovesSmoothlyThroughJitterAndLoss walks a peer around a circle. Samples come
every 6 ticks, up to 40 ms late, 5% are lost, and the client runs at 60 fps. The same scenario
replayed through the old walk: 96 of 599 frames stalled, 286 were off speed, and RMS
acceleration was 107 m/s^2. Now: no stalls, none off speed, 2.3 m/s^2 (the walk's own is 2.25).
@transfix
transfix merged commit d2a63b5 into master Nov 1, 2026
21 of 27 checks passed
@transfix
transfix deleted the feat/conf-aspect-peer-motion branch November 1, 2026 02:30
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