You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long-suspended data tasks holding full receive windows starve every Network.framework flow in the app process on tvOS — close-and-rerequest at high water would avoid the dormant state (field dose-response inside) #310
Context. tvOS 26 (AppleTV14,1 ×2), engine 6.7.0, persistent reader, direct-play VOD over LAN. Follow-on to #220's "suspend is advisory": this is what we now believe the long-suspended state does to the whole process.
Finding. During low-bitrate playback we see recurring 10–80 s episodes in which EVERY Network.framework-based flow in the app process goes deaf at once — established WebSockets stop receiving (dying of ETIMEDOUT ~30 s in, their sends unACKed), and no NEW nw flow completes a handshake (URLSession and bare NWConnection fail identically, -1001 at deadline, SYN-ACKs arriving on the wire unprocessed) — while in the same seconds raw BSD sockets from the same process complete TCP handshakes AND full plaintext HTTP exchanges 100% (229/229 in one evening), other processes on the box are unaffected, and the process is idle (4–18% CPU, ~16 threads parked, ~30 fds). On tvOS, TCP for nw flows runs in-process (user-space networking); everything observed is consistent with the process's nw inbound path stalling as a unit — beneath CFNetwork, above the kernel-socket path.
The dose-response tying it to reader dormancy. The reader suspends its data task at high water and can then sit dormant for long stretches holding a full unread receive window (a closed TCP window on an idle established flow). Dormant-stretch length is set by media bitrate (≈ window size / rate). Same fleet, same wire, three runs in 30 hours:
media rate
dormant stretch
episodes
~1.2 Mbps h264 1080p
~100 s
~11 in 80 min
~14 Mbps HEVC 4K
~8.5 s
1 in 54 min
~88 Mbps HEVC 4K
~1.4 s
0 in 118 min
A paused player is the limiting case (indefinite dormancy) and is where we've recorded the worst episode (11 unbroken minutes). The effect switches back on at will by returning to low-bitrate content.
Why the fix belongs at the reader even though the fault looks like Apple's. Nothing a session owner does dodges the stall once it starts — it hits fresh sessions and bare NWConnection equally. The escape is not entering the dormant state: the engine already ENDS the connection at the hard cap and re-requests on drain (#220's machinery); at low bitrates, though, suspend() engages first and the flow then sits dormant-established ~100 s per cycle. If the reader closed-and-rerequested at high water instead of suspending (or bounded how long a task may stay suspended before the conn is ended), the pathological state never forms — one extra range request per drain cycle (every ~100 s at 1 Mbps; ~2 ms connects on LAN), and a paused player would hold no dormant flow at all.
Happy to run any instrumented build — we have per-second probe arms (URLSession / NWConnection / raw-BSD) that make episodes and their absence directly measurable.
Fixed on main: #317 (1e45bf7) plus a follow-up in b2923b7. Reopened because the merge auto-closed it. The 71-minute two-device run already on record is the strongest evidence this has, so this stays open only until the same absence of episodes holds on a released build rather than a local branch.
What the shipped behaviour looks like:
At winHighWater the connection is ended, not suspended. The reader now either has an actively delivering flow or none at all, and a paused player holds none.
[AVIOReader] pump window high water: NMB ahead; ending the connection, will re-request at the frontier once the consumer drains is the cycle, one line per drain cycle rather than a silent park.
The memprobe reports pumpParked=1 while the end is recorded and the low-water refill has not fired. A long-lived Parked=1 with AheadMB holding above low water is a stalled consumer, not a transport fault.
New in the follow-up: if a transport ever ignores the cancel the way it ignored the suspend, that says so directly rather than showing up as a climbing window: gen=N NMB delivered AFTER the backpressure end; the cancel is not stopping this transport. Worth grepping for in the probe arms, since a silent version of that would be the one way this design fails.
The winHardCap escape hatch and the suspend machinery are gone with the suspend, so the window peak is now high water plus one delivery's in-flight overshoot.
Retested on a released build. Two Apple TV 4K (3rd gen), engine at the 6.12.0 tag (eb360a44), same ~1 Mbps h264 1080p title as the dose-response table's first row: a full 89-minute linear run to end of media with two deliberate ~3.5-minute pauses. Census over the whole window: zero starvation episodes — no WebSocket receive errors, no connection-setup timeouts, none of our detection arms (≥12 s delivery gap, relay stand-down, socket-down) ever triggered, zero player errors. The mechanism ran at the same cadence as the branch run: 136 high-water end-and-rerequest cycles per device (~one per 39 s), with the low-water refill winning every cycle (empty-window backstop: 0). Both pause windows held no connection at all — no reader activity for the full ~3.5 minutes, memprobe reading Parked=1 throughout, first refill on resume. Grepping for the follow-up's delivered AFTER the backpressure end line: 0 occurrences, so the cancel is stopping this transport. (The 6.12.0 delivery-gap watchdog also stayed correctly silent the whole run.) With the branch run, that's two independent zero-episode runs in the regime that produced 9–11 per 80 minutes. Fine to close from our side.
Thanks for running the full 89 minutes on two devices, and on the released tag. That is exactly the condition this was held open for, so it closes here.
What makes it more than a zero: the mechanism ran 136 times per device during the run. An absence of starvation episodes in a window where the backpressure path never engaged would say nothing; an absence across 136 end-and-rerequest cycles is measured in the regime that produced 9 to 11 episodes per 80 minutes. And the low-water refill winning every one of those cycles, with the empty-window backstop at 0, is the answer to the one cost this design took on: the extra request per drain cycle is a request, not a stall, because the consumer never reached an empty window waiting for it.
The zero on delivered AFTER the backpressure end is a measured absence rather than a filtered one, which is worth stating since that grep is the design's own failure witness. It is emitted from the same function as the high-water line, under the same category and the same release-visible level, with no debug gate on either. 136 occurrences of the one and 0 of the other in the same capture is a positive control for the channel. Its scope is worth naming too: the line latches once per connection generation and only fires once post-end delivery passes high water, so a bounded in-flight tail is invisible to it by design. What the zero rules out is unbounded delivery after the cancel, which is precisely how #174 and #220 each failed once. The finer figure is already in the capture: the MB number on each high-water line is ahead at the moment of ending, so it is high water plus whatever was in flight, and 136 samples of it bound the tail directly.
The pause windows are the part I would have wanted most, and they read the way the design intends: no connection held for ~3.5 minutes, Parked=1 throughout, first refill on resume. The 11-minute episode in the original dose-response came out of exactly that state, and there is now nothing there that can go dormant.
One arithmetic footnote, not a reason to hold this open. The water marks are 16 MB high, 8 MB low, so each cycle is 8 MB of drain and 136 of them is about 1.1 GB per device, which is above what a ~1 Mbps title consumes across the roughly 82 minutes of actual playback in that run. The likely reason is that the count spans two readers: the line carries the reader label, and a text subtitle track runs a subs reader alongside pump, doing its own backpressure cycles over the same file (on Matroska it reads every byte it discards, so its volume matches the pump's). Splitting the count by label, or reading the final pumpFetchedMB against the file size, tells the two apart. Either way it is the design working, once or twice over.
Closing. The report is one of the better ones this project has had: the BSD-socket control that separated an in-process substrate stall from a bad link, and the bitrate dose-response that turned a sporadic failure into a mechanism with a duration, are what made this fixable rather than a long hunt for a network flake.
The split is worth recording since it confirms the reading. Over the 89-minute window the high-water line appears 136 times per device, and by reader label that is 67 pump and 69 prefetch — the second reader being the subtitle side-demuxer, which takes .withReaderLabel("prefetch") and opens at offset=0, so it walks the whole file alongside the pump exactly as you described. The memprobe agrees: subTracks=1 subActive=true, prefetch=eof, prefetchHarvested=1480.
The pump's own figure settles the arithmetic directly. pumpFetchedMB ends at 587 on one device and 588 on the other, against a file of 614,623,172 bytes — 586.1 MB. The pump read the source once. The apparent gigabyte was two readers over one file, not a pump fetching more than the title contains.
Activity
Backpressure: end the connection at high water instead of suspending …
Merge pull request #317 from rrgomes/fix/310-backpressure-dormancy
Merge pull request #324 from superuser404notfound/fix/310-followup
superuser404notfound commentedon Aug 7, 2026
Fixed on main: #317 (1e45bf7) plus a follow-up in b2923b7. Reopened because the merge auto-closed it. The 71-minute two-device run already on record is the strongest evidence this has, so this stays open only until the same absence of episodes holds on a released build rather than a local branch.
What the shipped behaviour looks like:
winHighWaterthe connection is ended, not suspended. The reader now either has an actively delivering flow or none at all, and a paused player holds none.[AVIOReader] pump window high water: NMB ahead; ending the connection, will re-request at the frontier once the consumer drainsis the cycle, one line per drain cycle rather than a silent park.pumpParked=1while the end is recorded and the low-water refill has not fired. A long-livedParked=1withAheadMBholding above low water is a stalled consumer, not a transport fault.gen=N NMB delivered AFTER the backpressure end; the cancel is not stopping this transport. Worth grepping for in the probe arms, since a silent version of that would be the one way this design fails.The
winHardCapescape hatch and the suspend machinery are gone with the suspend, so the window peak is now high water plus one delivery's in-flight overshoot.superuser404notfound commentedon Aug 7, 2026
Shipped in 6.11.0. Still open until the absence of episodes holds on a released build rather than the branch.
diag(io): name a backpressure end the transport ignores (superuser404…
fix(io): notice a silently dead connection on wall-clock time (superu…
rrgomes commentedon Aug 7, 2026
Retested on a released build. Two Apple TV 4K (3rd gen), engine at the 6.12.0 tag (
eb360a44), same ~1 Mbps h264 1080p title as the dose-response table's first row: a full 89-minute linear run to end of media with two deliberate ~3.5-minute pauses. Census over the whole window: zero starvation episodes — no WebSocket receive errors, no connection-setup timeouts, none of our detection arms (≥12 s delivery gap, relay stand-down, socket-down) ever triggered, zero player errors. The mechanism ran at the same cadence as the branch run: 136 high-water end-and-rerequest cycles per device (~one per 39 s), with the low-water refill winning every cycle (empty-window backstop: 0). Both pause windows held no connection at all — no reader activity for the full ~3.5 minutes, memprobe readingParked=1throughout, first refill on resume. Grepping for the follow-up'sdelivered AFTER the backpressure endline: 0 occurrences, so the cancel is stopping this transport. (The 6.12.0 delivery-gap watchdog also stayed correctly silent the whole run.) With the branch run, that's two independent zero-episode runs in the regime that produced 9–11 per 80 minutes. Fine to close from our side.superuser404notfound commentedon Aug 7, 2026
Thanks for running the full 89 minutes on two devices, and on the released tag. That is exactly the condition this was held open for, so it closes here.
What makes it more than a zero: the mechanism ran 136 times per device during the run. An absence of starvation episodes in a window where the backpressure path never engaged would say nothing; an absence across 136 end-and-rerequest cycles is measured in the regime that produced 9 to 11 episodes per 80 minutes. And the low-water refill winning every one of those cycles, with the empty-window backstop at 0, is the answer to the one cost this design took on: the extra request per drain cycle is a request, not a stall, because the consumer never reached an empty window waiting for it.
The zero on
delivered AFTER the backpressure endis a measured absence rather than a filtered one, which is worth stating since that grep is the design's own failure witness. It is emitted from the same function as the high-water line, under the same category and the same release-visible level, with no debug gate on either. 136 occurrences of the one and 0 of the other in the same capture is a positive control for the channel. Its scope is worth naming too: the line latches once per connection generation and only fires once post-end delivery passes high water, so a bounded in-flight tail is invisible to it by design. What the zero rules out is unbounded delivery after the cancel, which is precisely how #174 and #220 each failed once. The finer figure is already in the capture: the MB number on each high-water line isaheadat the moment of ending, so it is high water plus whatever was in flight, and 136 samples of it bound the tail directly.The pause windows are the part I would have wanted most, and they read the way the design intends: no connection held for ~3.5 minutes,
Parked=1throughout, first refill on resume. The 11-minute episode in the original dose-response came out of exactly that state, and there is now nothing there that can go dormant.One arithmetic footnote, not a reason to hold this open. The water marks are 16 MB high, 8 MB low, so each cycle is 8 MB of drain and 136 of them is about 1.1 GB per device, which is above what a ~1 Mbps title consumes across the roughly 82 minutes of actual playback in that run. The likely reason is that the count spans two readers: the line carries the reader label, and a text subtitle track runs a
subsreader alongsidepump, doing its own backpressure cycles over the same file (on Matroska it reads every byte it discards, so its volume matches the pump's). Splitting the count by label, or reading the finalpumpFetchedMBagainst the file size, tells the two apart. Either way it is the design working, once or twice over.Closing. The report is one of the better ones this project has had: the BSD-socket control that separated an in-process substrate stall from a bad link, and the bitrate dose-response that turned a sporadic failure into a mechanism with a duration, are what made this fixable rather than a long hunt for a network flake.
rrgomes commentedon Aug 7, 2026
The split is worth recording since it confirms the reading. Over the 89-minute window the high-water line appears 136 times per device, and by reader label that is 67
pumpand 69prefetch— the second reader being the subtitle side-demuxer, which takes.withReaderLabel("prefetch")and opens atoffset=0, so it walks the whole file alongside the pump exactly as you described. The memprobe agrees:subTracks=1 subActive=true,prefetch=eof,prefetchHarvested=1480.The pump's own figure settles the arithmetic directly.
pumpFetchedMBends at 587 on one device and 588 on the other, against a file of 614,623,172 bytes — 586.1 MB. The pump read the source once. The apparent gigabyte was two readers over one file, not a pump fetching more than the title contains.fix(io): a live window absorbs the join burst once instead of cycling…
fix(io): an idle pin is dropped by its first refusal, not by the grace (
test(probe): a device harness for whether a held connection outlasts …
feat(io): an HTTP/1.1 read path over a demand-driven stream task (sup…
feat(io): the reader can hold one connection and pull it (superuser40…
feat(api): LoadOptions.heldSourceConnection, and aetherctl --held-con…
fix(io): the pause bound needs the watchdog to stand aside, and a pol…
fix(io): a held connection ends on a pause, not on a parked producer (#…
docs(io): the pause bound is half the longest dormancy measured clean (…
fix(io): a parked stretch is not a delivery gap (superuser404notfound…
perf(relay): never park the session's delegate queue for a consumer t…