Repository navigation
Description
What happened?
On every HTTP open, AVIOReader.open() calls probeFileSize() — a Range: bytes=0-0 GET — and then opens the real data connection (Range: bytes=0-) at offset 0. The persistent/streaming GET's 206 response already carries the total in Content-Range, so the standalone probe is a redundant extra round-trip. On origins that don't return a length for bytes=0-0, the probe also falls back to a second request (HEAD), so the open pays two size round-trips before the first byte is used (Range probe didn't yield a size, trying HEAD). Because the probe runs per demuxer-open (and the load path opens more than once), this multiplies and adds avoidable load that can help trip an origin's rate limiter. Expected: discover the size from the first data connection's response headers and skip the dedicated probe.
Steps to reproduce
- Point the engine at a remote MP4/MKV over HTTP(S) on an origin that does not return Content-Range/Content-Length for a Range: bytes=0-0 request (common behind some CDNs/proxies).
- engine.load(url:).
- Watch the [AVIOReader] logs: a Range probe … (or … trying HEAD) round-trip, immediately followed by the persistent connection's Range: bytes=0- GET to the same offset.
AetherEngine version or commit SHA
3.13.2
Host app
Sodalite
Platform
tvOS
OS version
27 beta
Device / chip
a19 pro / m2
Playback path
Native AVPlayer
Source media (for playback bugs)
MP4 (mov,mp4) and MKV over progressive HTTP(S); container-agnostic. Most visible on origins that omit length on bytes=0-0.
Error codes / log lines
[AVIOReader] File size: … bytes (Range probe) # probe round-trip #1
[AVIOReader] Range probe didn't yield a size, trying HEAD # round-trip #2 on some origins
[AVIOReader] Persistent conn start gen=1 offset=0 # the real GET, whose 206 Content-Range already has the total
Anything else
Proposed fix. Derive fileSize from the first data connection's response (Content-Range total on 206, or Content-Length on a from-0 200) and drop the standalone probeFileSize() for the common case; keep the Range/HEAD probe only as a fallback when the first response has no length (chunked/live → streaming mode, as today). Skipping the probe for isLive is a free win on its own (it otherwise burns the full Range timeout on transcode endpoints that reject Range).
The one constraint: the reader selects its mode (persistent/seekable/streaming) from fileSize before the first read, and usePersistentReader/isStreaming are recomputed from fileSize on every read(). Folding size-discovery into the first connection therefore wants an explicit mode latch decided at open time. That refactor is engine-internal, which is why I'm filing it here rather than working around it in the host.
Why it won't regress normal playback. Worst case (no length on the first response) is identical to today — fall back to the existing probe/HEAD. Best case skips 1–2 round-trips. .strm/live with no length still resolve to streaming mode by the same path.
Activity
fix(demux): derive remote size from the data connection, drop the red…
chore(release): prep 4.2.3 — derive remote size from the data connect…
superuser404notfound commentedon Jun 26, 2026
Fixed in 4.2.3.
The dedicated
probeFileSize()round-trip is gone for the playback path.AVIOReader.open()now starts the persistentRange: bytes=0-data connection first and folds the total straight out of its first response (206Content-Range, orContent-Lengthon a from-0 2xx), so the common case opens with zero extra round-trips. Live skips it as well, since its result was discarded anyway and the probe otherwise burned the full Range timeout on transcode endpoints that reject Range.The size oracle moving onto the data connection had one constraint worth calling out, because it is exactly the rate-limiter interaction you flagged: if it became the only size path, a transient open-time 429 (or a slow-header origin, or one whose length only comes via HEAD) would lose the independent probe's resilience and downgrade the whole session to seekless streaming. So when the data connection resolves no usable size, the open falls back to the exact prior probe path (
Range: bytes=0-then HEAD) on a separate connection and budget:Content-Range, noContent-Length) streams, as before.Your
bytes=0-overbytes=0-0observation is in too: the persistent connection already usedbytes=0-, and the remaining still-extraction probe now uses it as well, so the single-byte form that some origins special-case (omitting the length and then 429-ing the HEAD) is no longer on any path.Thanks for the precise diagnosis, the real-world
Range probe didn't yield a size, trying HEAD->HEAD failed (HTTP 429), streaming modechain, and the confirmed one-shot probe shape. It made the root cause and the safe scope unambiguous.perf(demux): bound the wedge-restart reopen open to a finite range (s…
fix(demux): an audio track with no decoder no longer costs the whole …