Skip to content

fix: republish a peer's tracks into each new occupancy (LUM-708) - #19

Merged
FrekiManagarm merged 1 commit into
feat/lum-553-stats-samplingfrom
feat/lum-708-republish-tracks
Nov 7, 2026
Merged

FrekiManagarm merged 1 commit into
feat/lum-553-stats-samplingfrom
feat/lum-708-republish-tracks

Conversation

@FrekiManagarm

@FrekiManagarm FrekiManagarm commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #18. Merge #18 first; GitHub then retargets this PR to main.

Summary

Fixes LUM-708. Telemetry keys tracks by occupancy (one per join), but TrackPublished only fired on str0m's MediaAdded, once per connection. So in three cases the new occupancy ended up with no track, and no TrackSample or TrackCodec was ever written for it:

  • a room switch;
  • a leave followed by a join;
  • an offer that arrives before the first join. The pump dropped the TrackAdded for lack of an occupancy.

Changes

  • On join (signaling/dispatch.rs): every m-line the connection already publishes (rx_kind) is republished into the fresh occupancy, right after PeerJoined, because tracks.peer_id references peers.id.
  • Telemetry::publish_track is now the single way to publish a track, used by both the transport pump and the join. It is idempotent: a TrackAdded still queued when the join runs does not publish twice. Without this, track_published would be duplicated in the events log, although tracks itself is protected by on conflict do nothing.
  • Telemetry::track_id, which mints an id without recording anything, is now #[cfg(test)]. It was the API that could produce orphan track ids.
  • impl From<MediaKind> for TrackKind replaces the inline mapping.

Test plan

  • dispatch tests:
    • a room switch republishes both tracks in the new occupancy, after PeerJoined, and room A's tracks are released;
    • a track published before the first join is recorded on join;
    • leave then join republishes;
    • a peer that publishes nothing gets no track.
  • First tests of the transport pump (signaling::session):
    • samples follow the track into its new occupancy, with the delta spanning the switch;
    • no sample is written without a published track;
    • a queued TrackAdded after the join does not publish twice.
  • Mutation check: making publish_track non-idempotent fails both idempotence tests.
  • cargo test (166 passed), cargo clippy --all-targets -- -D warnings, cargo fmt --check

Telemetry keys tracks by occupancy, but TrackPublished only fired on
str0m's MediaAdded, once per connection. After a room switch, a leave
then join, or an offer that beat the first join, the new occupancy had
no track: no TrackSample and no TrackCodec were ever written for it.

- on join, republish every m-line the connection already publishes,
  right after PeerJoined (tracks.peer_id references peers.id)
- Telemetry::publish_track is the single, idempotent way to publish: a
  TrackAdded still queued when the join runs does not publish twice
- the minting track_id is now test-only, so no orphan id can be made
- first tests of the transport pump: samples follow the track into its
  new occupancy, none without a published track, no duplicate publish
@FrekiManagarm
FrekiManagarm force-pushed the feat/lum-708-republish-tracks branch from a80c728 to 2ded39e Compare November 3, 2026 23:48
@FrekiManagarm
FrekiManagarm force-pushed the feat/lum-553-stats-sampling branch from 5efce3b to 362ff36 Compare November 3, 2026 23:48
@FrekiManagarm
FrekiManagarm merged commit 163c908 into feat/lum-553-stats-sampling Nov 7, 2026
2 checks passed
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