Repository navigation
Description
Device trace from Syravo on tvOS 26.6 / AetherEngine 6.34.1 (the lines below are 6.35.0, which did not touch any of them): a live MPEG-TS channel from an Xtream aggregator that answers with a 302 to a one-slot media host (maxConcurrentSourceRequests = 1, liveJoinProfile = .fastZap). The channel froze twice within a minute. Both times the cause was the origin — this is not a report of an engine bug that broke playback, but the trace shows four places where the engine's reading of the situation differed from what the origin did, and the recovery ran ~12 s longer and replayed already-seen content as a result. Full log available on request; the relevant lines are quoted inline.
The trace
[AetherEngine] #361 startup 8/8 presenting (gen 4)
… ← plays normally, fwd≈5 s
[AVIOReader] slow read: 19976ms at offset=21757952 detour=0(0ms,0fetch) stallWaits=20(19975ms,20signaled) tailWaits=0(0ms) reconnects=0 backoff=0ms … gen=1->1 origin=1inflight/1peak limit=1
[LagDiag] clk=20.70 … fwd=0.4 keepUp=y empty=n stall=0
[NativeAVPlayerHost] #4 playbackStalled
[AVIOReader] slow read: 5134ms at offset=22020096 … stallWaits=18(5134ms,18signaled) … reconnects=0
[HLSSegmentProducer] video timeline rebase (live): jumpTicks=8487014192 srcDts=8589934592 lastSrcDts=102920400 oldShift=100915200 newShift=8587927592 continuationDts=2007000
[HLSSegmentProducer] live seg-13 finalized: start=21.180s dur=1.180s
[HLSSegmentProducer] audio timeline rebase (live): jumpTicks=8487016832 srcDts=8589934832 …
[HLSSegmentProducer] live seg-14 finalized: start=22.360s dur=1.920s [DISCONTINUITY]
[HLSSegmentProducer] seg-15.m4s captured (764054 B) ← identical size to seg-6
[HLSSegmentProducer] seg-16.m4s captured (1044022 B) ← identical size to seg-7
[HLSSegmentProducer] seg-17.m4s captured (1690095 B) ← identical size to seg-8
[HLSSegmentProducer] seg-18.m4s captured (1793279 B) ← identical size to seg-9
[HLSSegmentProducer] seg-19.m4s captured (866448 B) ← identical size to seg-10
[NativeAVPlayerHost] #4 timeControlStatus=playing reason=- t+27.24s
…
[AVIOReader] origin connections: 0 of 4 reader connections reused at http://<aggregator>:80, every one paid a fresh handshake
[AVIOReader] Live source: connection ended gen=1 buffered=0KB; reconnect will fire when buffer drains
[AVIOReader] pump conn start gen=2 offset=34545940 open-ended
Received unexpected proxy response ← CFNetwork, twice per attempt
[AVIOReader] pump gen=2 rejected response status=407 at offset 34545940 from the pinned target <media host>
[AVIOReader] pump conn ended at offset 34545940 status=407, reconnecting (streak=1 retryAfter=0.0s)
[AVIOReader] pump conn start gen=3 offset=34545940 open-ended
[AVIOReader] pump gen=3 rejected response status=407 at offset 34545940 from the pinned target <media host>
[AVIOReader] pump conn ended at offset 34545940 status=407, reconnecting (streak=2 retryAfter=0.0s)
[AVIOReader] Dropped resolved URL cache (unproductive reconnect streak)
[NativeAVPlayerHost] #4 playbackStalled
[AVIOReader] pump conn start gen=4 offset=34545940 open-ended re-resolving through the source
… ← the aggregator answered this 302 within the second (server log); nothing arrived from the media host for the next 25 s
[AetherEngine] #65 re-engaging stalled AVPlayer (stall + 6s without fetches): nudge seek to 33.73s
[AetherEngine] #65 nudge did not revive the consumer; reloading item at the live edge (rejoin) (same URL, same host)
[NativeAVPlayerHost] #5 load url=http://127.0.0.1:55185/media.m3u8 startPos=nil headers=none
[HLSLocalServer] GET /seg18.mp4 … GET /seg19.mp4 … GET /seg20.mp4 … GET /seg21.mp4 ← the same tail again
[LagDiag] clk=28.85 dclk=28.85 tcs=playing … ← 5 s behind the frozen position (33.73)
[LagDiag] clk=31.86 … fwd=2.0
[AVIOReader] slow read: 28064ms at offset=34340864 … stallWaits=9(24972ms,9signaled) … reconnects=3 backoff=3089ms … gen=1->5
[HLSSegmentProducer] pump finished: reason=stopRequested … ← the viewer gave up at t+56 s
1. A trickling live origin defeats both stall detectors (AVIOReader)
The first freeze was 20 s of stallWaits=20(19975ms,20signaled) with reconnects=0. Every forward wait (AVIOReader.swift:1785) returned signalled, and checkDeliveryGap (:2550) re-arms on lastDeliveryAt, which appendPersistentData stamps on every byte — so an origin that delivers a handful of bytes per second holds the reader at "flowing" for as long as it likes, the 256 KB read never completes, and the producer's own watchdogs (which run between av_read_frame calls) cannot tick either. The request carries timeoutInterval = 0 and the long-lived session no resource timeout by design, so the reader is the only detector there is, and both of its detectors are zero-byte detectors, not throughput detectors.
Suggestion: let the delivery-gap verdict look at bytes delivered over the connStallTimeout window against a small floor (a few KB, or "less than one AVIO read in 20 s"), not at whether the last byte is younger than 20 s.
2. A forward-corrected timeline restart is not a source replay (HLSSegmentProducer)
What arrived after those 20 s was the origin's stream restarted from its ring buffer: raw DTS back at ~0 (FFmpeg's 33-bit wrap correction turned that into srcDts=8589934592 = 2³³ exactly, jumpTicks=+8487014192) and eleven seconds of frames the session had already played (seg-15…19 are byte-identical in size to seg-6…10). isSourceReplay (HLSSegmentProducer.swift:871-890) starts with guard jumpTicks < 0, so the one classifier that would have raised .sourceReplay → liveSourceReset never looks at it; the restart is absorbed as a programme boundary with EXT-X-DISCONTINUITY, and the viewer watches the same eleven seconds twice. The rebase itself is correct.
Suggestion: also accept a positive jump whose newDts mod 2³³ lands inside sourceReplayStartWindowSeconds of firstSeenDts mod 2³³ — the wrap-corrected shape of the same event. Whether that should end the pump (as the backward shape does) or merely be reported is your call; today the host cannot even see it (the rebase ends in a PresentationAxis seam and no published signal).
3. 407 is an untyped status (AVIOReader)
isResolvedExpiryStatus (AVIOReader.swift:221-223) knows 401/403/404/410, isRateLimitStatus 429/503/509, isResolvedHardServerError ≥500. A 407 falls through all three: no pin drop from the status, Retry-After unread, and recordReconnectAndShouldGiveUp (:1897) counts it against the full mid-stream cap of 12 once bytes have flowed; the pin is dropped only by the streak rule in dropPinIfTheRefusalCallsForIt (:1951-1957) at unproductiveReconnects >= 2. On a redirect chain a 407 from the pinned media host cannot mean "authenticate to your proxy" — the request went out direct, which is why CFNetwork logs it as an unexpected proxy response — it means the pinned lease is gone or an interception answered in its place, and the only productive move is the one the reader took on the second attempt: re-resolve through the source. Treating 407 (and arguably 402/451) as an expiry status would save the first wasted attempt and the CFNetwork noise.
4. The stage-2 reload does not ask whether the producer moved (#65 ladder)
With the source re-resolving and no bytes arriving, reloadStalledConsumerItem (AetherEngine.swift:2048) reloaded the unchanged local playlist with startPosition: nil and skipInitialSeek (LiveReloadPolicy.swift:22), so AVPlayer rejoined at edge-minus-holdback of a frozen playlist — 5 s behind the frozen position, replaying seg-18…21 — and parked again. The comments around the final rung (AetherEngine+Loading.swift:1206-1252) describe exactly this shape and bound it with stallReloadReviveGate, so it is known; what the ladder does not consult is the producer. liveContinuationPoint() / the finalized-segment count at the moment of the stall were available and unchanged, and that is the one fact that distinguishes "consumer died under a healthy producer" (stage 2 helps) from "producer is starved" (stage 2 replays the tail and costs a further 12 s before liveSourceReset).
Suggestion: gate stage 2 on a segment finalized since the stall; when none has, skip to liveSourceReset directly. For a starved origin that halves the time to the host's retune (12 s instead of 24 s) and removes the replayed tail.
Host side I have bounded this with a playhead-progress watchdog (10 s frozen clock → fresh load through the portal), which is the right place for the policy; these four are about what the engine could know by itself. Happy to split into separate issues or to measure any of it further against the same panel.
Activity
superuser404notfound commentedon Aug 23, 2026
Thanks, this is a good trace, and the framing is right: the origin caused both freezes, and what is
actionable is where the engine's reading of it differed. Three of the four are in 6.36.0. The
fourth I measured instead of building, and the measurement points somewhere neither of us was
looking.
4. Stage 2 now asks the producer
Built as you suggested. The ladder gated stage 2 on consumer fetches and on the position budget and
never on the producer, and the finalized-segment count was sitting right there: it is already the
currency of two other budgets (the reopen cycle and the muxer rebuild). Stage 2 now skips straight
to
liveSourceResetwhen nothing has been finalized since the stall.Two deliberate limits. A session with no local producer at all (a remote HLS route AVPlayer fetches
itself) reports
nilrather than zero, because the absence of a producer to ask is not an answerfrom one, and reading it as zero progress would turn every live stall on that route into an
immediate retune. And the two other paths into the same reload are untouched: the producer-driven
wedge re-anchor is triggered BY the producer (where "no segment since the trip" is the normal state,
not starvation), and the item-death chain has a dead item where a fresh one is the only move there
is.
3. 407 is typed now
Your reading of it is right and the CFNetwork line is the evidence: the request went out direct, so
on a redirect chain a 407 cannot be a proxy asking for credentials, and a genuinely configured proxy
is answered by URLSession's own auth challenge long before a status reaches us. It is a dead lease
or an interception, and re-resolving is the only productive move. 407 joins 401/403/404/410, and 402
and 451 with it (an expired subscription or a geo-refusing edge node, same shape: the source still
mints working targets, this one stopped being one). Rate-limit statuses stay out, since re-resolving
there spends the request a metered origin has no room for.
2. The axis reset is classified, but not by the criterion you proposed
Built, with a different anchor, and the reason is in your own numbers.
Your suggestion was to accept a positive jump whose
newDts mod 2^33lands withinsourceReplayStartWindowSecondsoffirstSeenDts mod 2^33. That would not have fired on thistrace.
firstSeenDtsis where THIS session joined the origin's ring, and the shift line says wherethat was:
videoShiftPts = firstActualVideoDts - desiredFirstVideoTfdtPts, sooldShift=100915200puts the join 1121 s into the origin's axis. The cross-check holds on two other numbers in the same
line:
lastSrcDts - oldShift = 2005200= 22.28 s of produced output, which is exactly whereseg-13 start=21.180 dur=1.180had reached, andcontinuationDts=2007000is that plus one frame.The restart lands at raw 0. Those are 1121 s apart against a 10 s window.
So the anchor for this shape cannot be the join point. A rewind lands near
firstSeenDtsbecausethe server restarted the PROGRAMME; an axis reset lands near ZERO no matter where we joined the
ring. The check is now
newDts >= 2^33andnewDts mod 2^33within the start window, which is thewrap-corrected shape of "the source renumbered its clock from zero".
There is also a second guard your suggestion does not address.
isSourceReplayrequires anunplanned source reconnect within the last 30 s, and this trace has
gen=1->1withreconnects=0:the origin renumbered on the connection it already held. Even with the sign fixed, that guard would
have thrown the case away. It is dropped for the axis-reset shape only. The rewind keeps it, because
there a rebuilt connection is what separates a replay from a programme boundary, whereas the axis
reset carries its own discriminator: a boundary inside one transport stream keeps its PCR axis
running, and a genuine 33-bit wrap after ~26.5 h arrives as a continuous correction rather than a
jump over the discontinuity threshold.
To your open question, whether it should end the pump or merely be reported: it ends the pump, same
as the backward shape. Both describe the same state, and reporting a state the host cannot act on
differently is not worth a second signal. Live-only, since a sequential origin's archive chunks
legitimately open their own axis at zero.
1. The trickle: measured, and the floor is not where the time goes
The diagnosis is right and worth stating plainly: both detectors are zero-byte detectors. The
forward wait is re-armed by every
winCond.broadcast(),checkDeliveryGapreadslastDeliveryAt,and the same function stamps both on every delivery, so an origin that delivers a handful of bytes
per second holds the reader at "flowing" for as long as it likes.
I reproduced it rather than reasoning about it. A 300 s MPEG-TS fixture behind a loopback origin
that delivers at 200 KB/s, then drops to 100 bytes once a second for 45 s on the connection it
already holds, then recovers. One delivery per second is the shape your trace has: every wait
signalled, nothing to show for it. One connection for the whole run,
Range: bytes=0-, noreconnects, which matches
gen=1->1.Arm A, 6.36.0 as shipped:
Those two lines are 30 ms apart. The producer's own no-cut watchdog classifies source
starvation on a 35 s window, and it fired at 48 s: the 13 s of overrun are exactly the time the read
was blocked. It was not slow to decide, it was unable to decide.
Arm B, the short read. I patched
readPersistentto return whatever is in hand rather than holdout for
requestSize(live only,totalRead > 0), which is what I expected to give the producer itscadence back. The slow-read line disappeared, so the patch was doing its job, and the watchdog fired
at 47 s instead of 48. One second.
The reason is the part that changes the conclusion. The producer's watchdog runs between
av_read_framecalls, andav_read_framedoes not return until a whole packet is assembled. At100 B/s that takes longer than the watchdog window no matter how short the reads underneath it are,
and there is no
interrupt_callbackon the format context, soav_read_framehas no upper bound atall. The short read moves the block up one layer; it does not remove it.
So the thing that made your case invisible is not the reader's floor, and not the read length. It is
that the no-cut watchdog is inline in the loop it watches, which makes it depend on exactly the
call it is supposed to time out. That is structurally the same defect #309 fixed on the reader side,
where the precondition that had to go was "a consumer must be blocked on it". The fix has the same
shape: lift the watchdog onto a timer and give it a way to interrupt
av_read_frame. That is achange in the demuxer core, so it is its own round rather than a patch tacked onto this one.
Your question about the floor is still worth answering, but it is now a smaller question: whether a
reader-side floor should exist in addition. That is what the byte count decides. Over the 20 s of
stallWaits=20(19975ms,20signaled), how many bytes did those twenty signalled waits deliver? Mytrickle was 100 B/s, which any floor separates from healthy traffic; a 64 kbit/s radio stream is
8 KB/s, which no useful floor separates from a struggling TV channel. If your origin sat near the
top of that range, the reader cannot be the layer, and the watchdog above is the whole answer.
Your host-side playhead watchdog is in the right place regardless. A 10 s frozen clock is a policy
call about what the viewer will tolerate, and that one is the host's to make.
tschuegy commentedon Aug 23, 2026
Thank you — 6.36.0 is pinned in Syravo (drop-in from 6.35.0 as advertised, FFmpegBuild unchanged at 2.4.3, both simulator schemes build and the suites pass; nothing in the client needed to move, since none of the three is opt-in).
Reading the diff against the trace, all three land on what the log actually showed:
liveProducerIsStarvedon the finalized-segment count is the right discriminator, and returning nil rather than zero where there is no local producer is the part I would have got wrong — the remote-HLS route has no producer to ask, and reading that as "nothing produced" would have turned every consumer-side stall there into a retune.newDts % 2^33instead offirstSeenDtsis the detail I flagged as easy to get wrong, and gating it live-only for Sequential-origin VOD: a 33-bit PTS wrap at an archive chunk seam is never rebased — cutter folds to the plan tail, playlist freezes, session dies on a refused re-anchor #368's archive chunks closes the hole my suggestion would have opened. Not requiring a recent reconnect is right for what the trace showed (gen=1->1,reconnects=0).On the fourth finding — your call convinces me and I withdraw the proposal. A floor of "one AVIO read in 20 s" is indeed a 102 kbit/s lower bound, and that hangs up on healthy low-bitrate live audio; I was reasoning from one 4 Mbit/s TS channel and generalised a throughput floor that has no business being one. Returning short while bytes are arriving puts the judgement where the information is, and I'd rather wait for that than have a byte floor.
For the interim: the host side is bounded by a playhead-progress watchdog (10 s of frozen clock on live TV, 1 s poll, then a fresh load through the portal). It fires ahead of the ladder either way, so the visible effect of this release for us is that a starved producer now reaches
liveSourceResetat ~12 s instead of ~24 s and stops replaying the tail on the way — which is what the ~12 s and the eleven seconds in the trace were.Happy to leave this open for the short-read work and to re-measure against the same panel once it lands; the channel reproduces every few days. If it is easier to track that separately, feel free to close this one and I'll open a narrow issue for the trickle alone.
superuser404notfound commentedon Aug 23, 2026
Thanks for pinning it and for confirming against the client. That is the retest that counts: a
simulator suite cannot tell me whether three changes are drop-in for a shipping consumer, and
"nothing in the client needed to move" is the claim I was making.
One correction on what stays open, because our summaries drifted apart there. The short read is
not the pending work. It was arm B. The slow-read line disappeared, so the patch did its job, and
the watchdog still fired at 47 s against 48. What is left after that patch is not a smaller version
of the problem, it is all of it.
And a correction to my own framing, which was more pessimistic than the code deserves. I wrote that
the fix needs a way to interrupt
av_read_frame, as if that had to be built. It exists.Demuxer.markClosed()makes the AVIO read callback return -1 andav_read_framereturn at once,freeing nothing. It is what the #79 reopen path uses to unblock a wedged read, and the session
teardown already pairs it with the producer's own
stop()for precisely the reason at issue here, acancel flag cannot reach a thread parked in a read. The no-cut watchdog is the one decision on that
path with no such pairing, and its exit tears the session down anyway, so it has nothing to preserve
across an abort.
What makes it its own round is not the abort. It is that the #177 slow-delivery hold re-arms the
watchdog window from the read thread and keeps its anchor and counters in the read loop's locals.
Moving the decision onto a timer moves that state under a lock, and a race lost there turns a hold
into a retune, which is the single outcome the hold exists to prevent.
On tracking: taking you up on the split, with the halves the other way round. This one is
closed, since the three fixes are in and confirmed on your side, and the trickle is now #406 with
the reproduction, both arms, the fix shape and the two things it must not get wrong written down.
Your handle is on it, so it should reach your notifications. The harness is about fifteen minutes to
rebuild whenever the panel next reproduces, so re-measuring the same channel stays cheap.
One expectation to set for that round: for Syravo the visible effect will be nothing at all. Your
playhead watchdog fires at 10 s and the producer's starvation window is 35 s, so it beats both the
current 48 s and the fixed 35 s. The round is for hosts that do not have your watchdog, and the
~12 s against ~24 s you measured is already the whole of what 6.36.0 bought you.
fix(engine): stage 2 asks the producer before replacing the consumer'…
fix(engine): 407 on a redirect chain is a dead lease, not an untyped …
fix(engine): a source that renumbers its clock from zero is a restart…
fix(live): an ad seam's clock restart is a seam, and audio follows an…