Skip to content

diag(live): the first live manifest names the interval it held (#374) - #383

Merged
superuser404notfound merged 1 commit into
mainfrom
diag/live-first-serve-interval
Aug 16, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
diag/live-first-serve-interval

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

A loopback live session's entire join latency is one withheld /media.m3u8 response, and until now only a failed gate said so.

What the gate does

The first serve holds until the window carries the live-edge holdback (3 x TARGETDURATION, #189) of content behind the edge, because serving earlier puts AVPlayer's opening seek inside its own stall-danger zone and it restarts in a loop instead of playing. Everything else the engine does for that session finishes before the gate is entered.

Measured on 6.27.0 with aetherctl live against a paced raw-MPEG-TS origin, same machine and fixture, varying only the backlog the origin holds at join:

backlog at join first readyToPlay
0 s (strict realtime) 18.66 s
6 s 12.70 s
12 s 6.75 s
30 s 0.43 s

The startup ladder reached sessionConstructed at +0.19 s in every one of them. The wait is the runway being filled at whatever rate the origin hands it over, and nothing else.

What changes

Every exit from the gate now names what it held, the window it served and the holdback it was measured against:

[HLSVideoEngine] first live manifest served after 18.154s: 5 segments / 20.000s >= 18.000s holdback (TARGETDURATION 6s)
[HLSVideoEngine] first live manifest served after 0.088s: 5 segments / 20.000s >= 18.000s holdback (TARGETDURATION 6s)
[HLSVideoEngine] first live manifest served after 10.284s: 2 segments / 10.000s < 15.000s holdback (TARGETDURATION 5s), fastZap bounded start after 2.000s grace

Two exits change more than their wording:

  • The bounded .fastZap start reported its grace alone, which is the last leg of the wait rather than the wait. The third line above described itself as 2.000s before this change, having held for 10.284s.
  • The exit where no segment was ever cut returned in silence, which from a host's side is the one outcome indistinguishable from a merely slow origin. It now says so.

The interval is monotonic, because it is a measurement; the deadline stays on Date because NSCondition.wait(until:) takes one. One account per session, latched under firstSegmentCondition, since every /media.m3u8 without an _HLS_msn re-enters the gate.

docs/api.md gains Where a live start's seconds go: the mechanism, the fact that startupProgress stalls at sessionConstructed for the whole wait (which separates it from streamsProbed and routed), and liveJoinProfile as the lever with the honest caveat that the win belongs to the source GOP rather than to the flag.

Test plan

  • Issue374FirstServeAccountTests, 7 tests, all seen red first: four pin the account line (interval, holdback derived from TD rather than taken on trust, the >= / < verdict, and that a free runway still gets a line), three drive the gate itself (exactly one account across repeated requests, the bounded start naming the whole wait, the never-cut exit speaking).
  • Full suite green: 529 XCTest (1 skipped) + 1865 swift-testing in 270 suites.
  • tvOS simulator: ** BUILD SUCCEEDED **.
  • End to end on macOS with aetherctl live, all three shapes above, against the paced fixture origin at --preroll 0 and --preroll 30 plus a long-GOP seed under --fast-zap.

Raised by @ksktech-dev while measuring AetherEngine against libVLC across their device matrix (#374).

A loopback live session's entire join latency is one withheld `/media.m3u8`
response. The first serve holds until the window carries the live-edge holdback
(`3 x TARGETDURATION`, #189) of content behind the edge, and everything else the
engine does for that session is finished before the gate is entered. Measured
against a paced raw-MPEG-TS origin on 6.27.0, the startup ladder reached
`sessionConstructed` at +0.19 s in every arm, while the first `readyToPlay`
landed at 18.66 s, 12.70 s, 6.75 s and 0.43 s for 0, 6, 12 and 30 s of origin
backlog: the wait is the runway being filled at whatever rate the origin hands
it over, and nothing else.

Only a FAILED gate logged. A successful eighteen-second hold left no trace at
all, so a downstream host measuring a slow live start had no way to tell this
apart from a slow probe without instrumenting from the outside. Every exit now
names what it held, the window it served and the holdback it was measured
against:

    first live manifest served after 18.154s: 5 segments / 20.000s >= 18.000s holdback (TARGETDURATION 6s)

Two of those exits change more than their wording. The bounded `.fastZap` start
reported its grace alone, which is the last leg of the wait rather than the
wait, so a start that had held 10.284 s described itself as 2.000 s. And the
exit where no segment was ever cut returned in silence, which from a host's
side is the one outcome indistinguishable from a merely slow origin.

The interval is monotonic, because it is a measurement; the deadline stays on
`Date` because `NSCondition.wait(until:)` takes one. One account per session,
latched under `firstSegmentCondition`, since every `/media.m3u8` without an
`_HLS_msn` re-enters the gate and a steady session would otherwise repeat the
line at its refresh interval.

`docs/api.md` gains the paragraph that says where a live start's seconds go, and
how `startupProgress` stalling at `sessionConstructed` separates this wait from
the demux probe and the display handshake.

Raised by ksktech-dev while measuring AetherEngine against libVLC across their
device matrix (#374).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01E5UztmCZtNYPQpzdmSdmWG
@superuser404notfound
superuser404notfound merged commit a6e50d3 into main Aug 16, 2026
4 checks passed
@superuser404notfound
superuser404notfound deleted the diag/live-first-serve-interval branch August 16, 2026 21:08
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