IosSafeHttpDataSource: drop chunk size from 1 MiB to 512 KiB

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.
This commit is contained in:
Kayos 2026-05-24 14:42:13 -07:00
parent a7b058031b
commit 1df904f8b3

View file

@ -162,6 +162,12 @@ class IosSafeHttpDataSource(
} }
companion object { 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
} }
} }