Repository navigation
Description
What happened?
VOD playback (routed through the native/loopback HLS-ingest pipeline — HLSVideoEngine + HLSSegmentProducer + HLSLocalServer) crashes with EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded, limit=3376 MB) after several minutes of otherwise-normal playback.
The engine's own memprobe shows the growth is dominated by compressed memory, not resident/active memory:
t=511s rss=651MB vmInt=606MB vmExt=42MB vmCmp=1916MB physFP=2536MB mallocBlocks=1459697 mallocMB=2401 avioFetchedMB=542 cacheMB=482 subTracks=102 subActive=false
t=541s rss=558MB vmInt=515MB vmExt=42MB vmCmp=2421MB physFP=2950MB mallocBlocks=1606681 mallocMB=2810 avioFetchedMB=576 cacheMB=514 subTracks=102 subActive=false
vmCmp climbs ~500MB in 30 seconds while rss stays flat (and even drops slightly) — memory that was allocated, went cold, and got compressed rather than freed. subActive=false/subCues=0 throughout, so this is unrelated to #166 (already fixed in 5.15.5, confirmed).
At the moment of the crash (device paused in the debugger on the EXC_RESOURCE), I checked every AetherEngine-owned thread's stack:
AetherEngine.HLSSegmentProducer.pump(serial): blocked inHLSSegmentProducer.runPumpLoop()->advanceMuxer(to:)->awaitBackpressureRelease(target:head:context:)->SegmentCache.awaitFetchHighWater(reaching:timeout:)->NSCondition.waitUntilDate:->__psynch_cvwait. Correctly backpressured, waiting for the consumer to catch up before muxing more.com.aetherengine.hls.accept(serial): blocked inHLSLocalServer.acceptLoop()->__accept. Idle, waiting for a new loopback connection.com.aetherengine.hls.work(concurrent): blocked inHLSLocalServer.handleConnection(_:)->readHTTPRequest(_:)->__recvfrom. Idle, waiting for AVPlayer's next segment request.- The crashing thread (
com.apple.network.connections, serial): the only one actively executing — mid-read:_platform_memmove<-SSL_peek<-SSL_read<-boringssl_session_read<-nw_boringssl_read<-nw_protocol_boringssl_input_available(alllibboringssl.dylib). This is a live TLS read from the real HTTPS origin (HLSLocalServeritself is loopback BSD sockets, no TLS, so this has to be the source-side network fetch, i.e.AVIOReader).
So at the instant of the crash: everything downstream of the network fetch (muxing, serving to AVPlayer) is idle and properly paused on backpressure, but the upstream network read is still actively busy pulling bytes. AVIOReader's persistent-mode reader is documented to backpressure the network thread once window is more than winHighWater (16 MB) ahead of the consumer's read position (appendPersistentData, blocking until ahead <= winHighWater) — but if the muxer/pump is stalled and the network thread is still churning regardless, that cap isn't holding here, and whatever it keeps reading accumulates (and eventually gets compressed rather than reclaimed) instead of pausing along with the rest of the pipeline.
Steps to reproduce
- Load a VOD title through the native/loopback HLS pipeline (not
nativeRemoteHLSbypass) with subtitles inactive (rules out Unbounded aggregate memory growth in SubtitlePacketStore — per-stream cap exists, but nothing bounds the total across concurrent subtitle streams #166). - Play normally; the engine's own
memprobeshowsvmCmp/mallocMB/physFPclimbing steadily, uncorrelated withcacheMB(the bounded, tracked segment cache) oravioFetchedMBgrowing at a merely-linear rate. - After several minutes (varies by title — as fast as ~3 min on one source, longer on others), the app is killed by
EXC_RESOURCEat the configured memory limit. - Pausing in the debugger at the crash and inspecting every AetherEngine thread shows the pattern above: muxer/server threads idle and backpressured, only the upstream network-read thread still active.
AetherEngine version or commit SHA
5.15.5 / 49dcac1
Host app
Custom / my own integration
Platform
iOS
OS version
iPadOS 26.5 (build 23F77)
Device / chip
iPad (10th generation)
Playback path
Native AVPlayer (loopback HLSLocalServer/HLSVideoEngine/HLSSegmentProducer pipeline)
Source media (for playback bugs)
VOD title, subTracks=102, audioTracks=2, subtitles inactive throughout (subActive=false, subCues=0).
Error codes / log lines
Thread 36 Queue: com.apple.network.connections (serial)
EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded (limit=3376 MB))
0 _platform_memmove (libsystem_platform.dylib)
1 SSL_peek (libboringssl.dylib)
2 SSL_read (libboringssl.dylib)
3 boringssl_session_read (libboringssl.dylib)
4 nw_boringssl_read (libboringssl.dylib)
5 nw_protocol_boringssl_input_available (libboringssl.dylib)
[AetherEngine] memprobe t=511s rss=651MB vmInt=606MB vmExt=42MB vmCmp=1916MB vmIOS=0MB physFP=2536MB mallocBlocks=1459697 mallocMB=2401 avioFetchedMB=542 cacheCount=131 cacheMB=482 packetsWritten=13578 srvConns=1 srvBytesMB=446 srvSfMB=426 pktAlive=3 pktTotal=298314 subCues=0 audioTracks=2 subTracks=102 subActive=false avBufAhead=4.4s avBufBehind=30.9s seams=1
[AetherEngine] memprobe t=541s rss=558MB vmInt=515MB vmExt=42MB vmCmp=2421MB vmIOS=0MB physFP=2950MB mallocBlocks=1606681 mallocMB=2810 avioFetchedMB=576 cacheCount=138 cacheMB=514 packetsWritten=14217 srvConns=1 srvBytesMB=467 srvSfMB=447 pktAlive=3 pktTotal=299789 subCues=0 audioTracks=2 subTracks=102 subActive=false avBufAhead=6.0s avBufBehind=31.7s seams=1
Anything else
Suggested fix direction: audit whether AVIOReader's persistent-mode read (appendPersistentData/winHighWater) is actually gated to the muxer's consumption position when the reader is feeding HLSSegmentProducer, rather than only to its own internal read cursor. If the backpressure check is comparing against a position that keeps advancing independent of the stalled muxer (e.g. tracking bytes handed to a demuxer/parse step rather than bytes actually consumed by the muxer/SegmentCache), the network thread would keep reading and retaining data well past the intended 16MB window exactly when the muxer pauses — matching what we observed here.
Confirmed independently that Instruments' Allocations instrument (malloc stack logging, "Live Allocations Only") does not show this growth in tracked heap/anonymous-VM allocations even during a run that later hit this same EXC_RESOURCE — consistent with the growth living in compressed/inactive pages the app never frees rather than a straightforward heap leak.
Activity
Merge pull request #175 from superuser404notfound/fix/174-avio-persis…
superuser404notfound commentedon Jul 21, 2026
Root cause found, fixed in 5.17.3.
Your suggested audit direction pointed at the right layer, with one twist: the backpressure gate in
appendPersistentDatawas comparing against the correct position (the demuxer's actual consumption cursor, not an independently advancing one), and it did engage. The defect was the mechanism itself. The persistent reader applied backpressure by blocking the delegate callback until the window drained belowwinHighWater, and blocking a URLSession delegate has no flow-control contract. Whether the connection stops reading from the socket is a transport implementation detail:That matches every number in your report:
avioFetchedMBcounts bytes actually delivered into the reader's window, and it grew at playback rate (~34 MB per 30 s, consistent withcacheMB), whilemallocMBgrew ~409 MB per 30 s, which is the origin's line rate. The delta is the transport's undelivered backlog: written once, read much later, so it goes cold and lands in the compressor (vmCmpclimbing ~500 MB per 30 s while rss stays flat), in small blocks at ~4.9k new blocks per second (yourmallocBlocksdelta, ~2-3 KB average), which is TLS-record-fragment sized. It also explains the Allocations observation, since the growth sits in transport-internal buffering rather than anything the app-level live-allocation view attributes.The fix (#175): the persistent reader now uses task suspend/resume, the contractual flow control ("a task, while suspended, produces no network traffic"), the same mechanism the engine's streaming-mode reader already used. Delivery never blocks; the task suspends once the window exceeds the 16 MB high-water mark, and the read loop resumes it when the drain crosses the new 8 MB low-water mark (or before parking in the frontier wait, where a suspended task would never deliver). Every reconnect and teardown path balances a pending suspend before cancel. The window can still overshoot the high-water mark by the transport's in-flight amount (a few MB), which is bounded.
Could you retest your repro on 5.17.3? Expected in your memprobe series:
mallocMB/physFPplateau nearavioFetchedMB + cacheMBinstead of running away,vmCmpstays flat, and the source fetch turns bursty (the connection parks, then resumes in ~8 MB drains as playback consumes).Thanks for an exceptional report. The per-thread stack sweep at the crash instant plus the memprobe series pointed at the exact failing layer, and the delivered-vs-allocated split in your own counters is what confirmed the transport-buffering theory.
fix(demux): suspend the persistent transfer for backpressure instead …
fix(demux): bound the persistent read window when the transport ignor…
diag(demux): report the native path's reader window too (#220)
Merge #220: bound the persistent read window, plus the diagnostics th…
diag(io): name a backpressure end the transport ignores (superuser404…
test(probe): a device harness for whether a held connection outlasts …
feat(source-cache): validators, no dropped writes, a reviewed budget,…