From 1df904f8b345b0e5d58fe78c4dc1729202e4c123 Mon Sep 17 00:00:00 2001 From: Kayos Date: Sun, 24 May 2026 14:42:13 -0700 Subject: [PATCH] IosSafeHttpDataSource: drop chunk size from 1 MiB to 512 KiB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Curl matrix on Lucy egress (2026-05-24) against a fresh iOS audio URL showed YT enforces a per-request Range cap of roughly 900 KiB on iOS-bound googlevideo URLs: bytes=0-524287 (~512 KiB) -> 206 bytes=0-786431 (~768 KiB) -> 206 bytes=0-917503 (~896 KiB) -> 206 bytes=0-999999 (~977 KiB) -> 403 bytes=0-1048575 (~1 MiB) -> 403 Audio (itag 251) hits this cap; large video (itag 248) didn't trip it on the first chunk but would on any later read. 512 KiB chunks give a 2x safety margin under the observed ceiling. This finally explains why vc=17 still 403'd after the bounded-Range fix landed — the bound itself was over the cap. --- .../kotlin/com/sulkta/straw/net/IosSafeHttpDataSource.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/strawApp/src/main/kotlin/com/sulkta/straw/net/IosSafeHttpDataSource.kt b/strawApp/src/main/kotlin/com/sulkta/straw/net/IosSafeHttpDataSource.kt index 4e9eb7583..ffb92672f 100644 --- a/strawApp/src/main/kotlin/com/sulkta/straw/net/IosSafeHttpDataSource.kt +++ b/strawApp/src/main/kotlin/com/sulkta/straw/net/IosSafeHttpDataSource.kt @@ -162,6 +162,12 @@ class IosSafeHttpDataSource( } companion object { - const val DEFAULT_CHUNK_BYTES: Long = 1L * 1024 * 1024 + // YT's iOS-bound googlevideo URLs accept bounded `Range: bytes=N-M` + // requests up to roughly 900 KiB before flipping to 403. Empirically + // measured 2026-05-24 on Lucy egress: bytes=0-917503 (~896 KiB) → 206; + // bytes=0-999999 (~977 KiB) → 403. 512 KiB gives a 2× safety margin — + // small enough to survive future tightening, large enough to keep the + // open() round-trip count tolerable for a long video. + const val DEFAULT_CHUNK_BYTES: Long = 512L * 1024 } }