Repository navigation
fix(playback): make the stall watchdog level-triggered with a host escalation rung - #342
Conversation
…calation rung The superuser404notfound#65 stall re-engage watchdog was one-shot and edge-triggered: armed per playbackStalled notification, then a single instantaneous check 6 s later. Any media fetch inside that grace window disarmed it PERMANENTLY. Field trace: a live playlist froze at its last segment, AVPlayer drained the remaining tail (fetches during the grace window killed the watchdog), then parked in waitingToMinimizeStalls with ~2 s buffered — a state in which playbackStalled never re-fires, a waiting player never posts failedToPlayToEndTime, and the producer-side wedge detector had died with the pump. No recovery layer ever re-examined the session; the freeze was terminal from the couch. Three changes, smallest that closes every exit from that trap: - Level re-watch: fetch activity during the grace window re-baselines and keeps watching (bounded by maxStallWatchPasses) instead of returning permanently; only a fully silent window escalates into the unchanged nudge/reload ladder. - Persistent reload budget (storm shape): on a frozen playlist each stage-2 reload replays the tail and re-stalls within seconds, and the fresh stall supersedes the ladder task before any post-reload check can run — so a per-task rung alone can never fire. A gate spanning stall events (same shape as the superuser404notfound#93 item-death gate) admits two reloads at the same frozen position, then the ladder publishes liveSourceReset instead of reloading again. - Post-reload rung (silent-park shape): when no further stall supersedes, a rendered clock that has not moved a whole window after the stage-2 reload while the player still waits publishes liveSourceReset — the local session is unrecoverable consumer-side and only the host can retune. Co-Authored-By: Claude Fable 5 <[email protected]>
549f010
into
superuser404notfound:main
…ether it changed Follow-up to #342. The level re-watch and the reload budget are right. The post-reload rung tests `clockNow == clockAtReload`, and its own doc comment promises something else ("has not moved a whole window"). Exact equality is the wrong question here because stage 2 is an in-place swap: a swap that half took parks the FRESH item on its own clock, or on zero before it is ready, while being exactly as dead as a frozen one. Equality reads that as recovery, so the rung would sit out the shape it was written for. Now it asks whether the clock advanced past the same 0.5 s progress epsilon the item-death gate and the deferred-failure check already use. Widening it is safe because the clock was never the false-positive guard, `isWaitingToPlay` is: a consumer that recovered reports `.playing`, and nothing reaches this rung without a stall, two silent grace windows and a stage-2 reload in front of it. Tests: the two rung cases each moved one variable at a time (the old "moved clock" case flipped the clock AND the player state, so it pinned neither), plus the parked-on-a-different-clock case the equality test missed. CHANGELOG entry, and the em-dashes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
|
Merged. Verified onto current main (the branch was based on 6.15.2): 1689 swift-testing plus 477 XCTest green, tvOS Simulator build clean, and the watch cap is load-bearing (flipping The trap analysis holds all the way down. One change on top in b4956c1: the final rung asked whether the clock CHANGED, while its own doc comment promised whether it moved. Since stage 2 is an in-place swap, a swap that half took parks the fresh item on its own clock (or on zero before it is ready) and is exactly as dead, but equality reads that as recovery, so the rung would sit out the shape it exists for. It now asks whether the clock advanced past the same 0.5 s progress epsilon Also split the two rung tests so each moves one variable (the old moved-clock case flipped the clock and the player state together, so it pinned neither) and added the parked-on-a-different-clock case. Worth naming for the retest, since it is inherited rather than new: the escalation still triggers on a full grace window with zero segment REQUESTS while waiting, and the level re-watch gives that condition 60 s of chances instead of 6. A link slow enough to spend more than a window on a single segment can therefore reach the nudge where it previously would not. Two silent windows are still required for the reload, so the exposure is the same shape as before, just observed for longer. |
Problem
The #65 stall re-engage watchdog is one-shot and edge-triggered: armed per
playbackStallednotification, then a single instantaneous check 6 s later. Any media fetch inside that grace window disarms it permanently — only a newplaybackStalledre-arms.Field trace: a live playlist froze at its last segment (pump death; recovery arm added in #341). AVPlayer stalled, drained the remaining tail segments (fetches inside the grace window → watchdog dead), then parked in
waitingToMinimizeStallswith ~2 s buffered:In that parked state nothing can ever fire again:
playbackStalledneeds a buffer-exhaustion transition (buffer stays non-empty), a waiting player never postsfailedToPlayToEndTime, and the producer-side wedge detector died with the pump. The freeze was terminal from the couch.Fix
Three changes; together they close every exit from the trap:
Level re-watch. Fetch activity during the grace window re-baselines and keeps watching (bounded by
maxStallWatchPasses = 10≈ 60 s) instead of returning permanently. Only a fully silent window escalates into the unchanged nudge → stage-2-reload ladder; a recovered/paused/failed player still disarms (those states have other owners). Verdict extracted as a pure function.Persistent reload budget (storm shape). On a frozen playlist each stage-2 reload replays the tail and re-stalls within seconds, and the fresh stall supersedes the ladder task before any post-reload check can run — a per-task rung alone can never fire. A gate spanning stall events (same shape and epsilon as the Loopback-HLS: a single backward seek on heavy 4K can wedge the segment producer (video stalls, audio continues -> A/V desync) #93 item-death gate) admits two reloads at the same frozen position; after that the ladder publishes
liveSourceResetinstead of reloading again. Real progress restores the budget.Post-reload rung (silent-park shape). When no further stall supersedes, a rendered clock that has not moved a whole window (12 s) after the stage-2 reload while the player still waits publishes
liveSourceReset: the local session is unrecoverable consumer-side and only the host can retune. Live-gated; decision extracted as a pure function.liveSourceResetis the existing host contract ("negotiate a fresh URL and call load"); this only adds the two missing publishers for consumer-side dead ends.Tests
StallWatchdogLevelRearmTestspins the incident case (fetch-during-grace must re-watch, not disarm), escalation on silence, disarm on recovery/failure/cap, the frozen-clock rung (live-only), and the storm-shape budget (two reloads at a frozen position, then escalate; progress restores).🤖 Generated with Claude Code