Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Harden VOD retry regression coverage

David Nashashe610d2c5e67c
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 1c15ffd9..e6e0ec70 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -16,6 +16,7 @@ All notable product changes are recorded in this document.
- Improved playback interruption diagnostics to distinguish rebuffering from dropped frames and track interruption durations more accurately.
### Fixed
+- Fixed interruptions during on-demand playback when an idle connection closes, by retrying the interrupted download in place.
- Fixed Android TV guide publication failing when the platform rejects SQL filters on programme queries.
- Fixed eligible live MPEG-TS channels remaining unavailable after an Android TV-input video surface was recreated; playback now makes one safe recovery attempt.
- Fixed interrupted Stalker guide downloads being marked fresh and losing automatic retry; useful partial guide data is retained until a complete refresh succeeds.
diff --git a/player/src/test/java/com/streamvault/player/playback/IdleConnectionResetRecoveryTest.kt b/player/src/test/java/com/streamvault/player/playback/IdleConnectionResetRecoveryTest.kt
index e519e0f7..ddebeb52 100644
--- a/player/src/test/java/com/streamvault/player/playback/IdleConnectionResetRecoveryTest.kt
+++ b/player/src/test/java/com/streamvault/player/playback/IdleConnectionResetRecoveryTest.kt
@@ -145,7 +145,8 @@ class IdleConnectionResetRecoveryTest {
val resume = server.requests[1]
assertThat(resume.status).isEqualTo(206)
assertThat(resume.rangeStart).isAtLeast(1_000_000L)
- assertThat(resume.rangeStart).isAtMost(server.requests[0].bytesSent)
+ // A write interrupted by close may still deliver part of its current chunk.
+ assertThat(resume.rangeStart).isAtMost(server.requests[0].bytesSent + 16 * 1024L)
}
private fun idleFor(ms: Long) {
diff --git a/player/src/test/java/com/streamvault/player/playback/PlayerRetryPolicyTest.kt b/player/src/test/java/com/streamvault/player/playback/PlayerRetryPolicyTest.kt
index 1110abd4..ccb35de3 100644
--- a/player/src/test/java/com/streamvault/player/playback/PlayerRetryPolicyTest.kt
+++ b/player/src/test/java/com/streamvault/player/playback/PlayerRetryPolicyTest.kt
@@ -504,6 +504,52 @@ class PlayerRetryPolicyTest {
assertThat(policy.shouldRetry(error, liveContext, playbackStarted = true, attempt = 11)).isFalse()
}
+ @Test
+ fun `body read retries remain bounded for live and on demand hls`() {
+ val error = HttpDataSource.HttpDataSourceException(
+ java.net.ProtocolException("unexpected end of stream"),
+ DataSpec.Builder().setUri("https://example.com/segment.ts").build(),
+ PlaybackException.ERROR_CODE_IO_UNSPECIFIED,
+ HttpDataSource.HttpDataSourceException.TYPE_READ
+ )
+ val vodContext = liveContext.copy(playbackContentKind = PlaybackContentKind.ON_DEMAND)
+ val vodPolicy = PlayerRetryPolicy(vodContext) { true }
+
+ assertThat(policy.maxAttempts(error, playbackStarted = false)).isEqualTo(10)
+ assertThat(policy.maxAttempts(error, playbackStarted = true)).isEqualTo(10)
+ assertThat(vodPolicy.maxAttempts(error, playbackStarted = true)).isEqualTo(2)
+ assertThat(vodPolicy.shouldRetry(error, vodContext, playbackStarted = true, attempt = 3)).isFalse()
+ assertThat(policy.getFallbackSelectionFor(fallbackOptions(2, 2), loadError(0, exception = error))).isNull()
+ }
+
+ @Test
+ fun `body read wrappers do not turn terminal ssl or malformed errors into retries`() {
+ val dataSpec = DataSpec.Builder().setUri("https://example.com/segment.ts").build()
+ fun readFailure(cause: IOException) = HttpDataSource.HttpDataSourceException(
+ cause, dataSpec, PlaybackException.ERROR_CODE_IO_UNSPECIFIED,
+ HttpDataSource.HttpDataSourceException.TYPE_READ
+ )
+ val ssl = readFailure(SSLHandshakeException("certificate verify failed"))
+ val malformed = readFailure(ParserException.createForMalformedContainer("bad segment", null))
+
+ assertThat(PlayerErrorClassifier.classify(ssl)).isEqualTo(PlaybackErrorCategory.SSL)
+ assertThat(policy.maxAttempts(ssl, playbackStarted = true)).isEqualTo(0)
+ assertThat(PlayerErrorClassifier.classify(malformed)).isEqualTo(PlaybackErrorCategory.SOURCE_MALFORMED)
+ assertThat(progressivePolicy.maxAttempts(malformed, playbackStarted = true)).isEqualTo(0)
+ }
+
+ @Test
+ fun `live timestamp dependency timeout remains limited when wrapped as a body read`() {
+ val error = HttpDataSource.HttpDataSourceException(
+ IOException(java.util.concurrent.TimeoutException("TimestampAdjuster failed to initialize in 30000 milliseconds")),
+ DataSpec.Builder().setUri("https://example.com/segment.ts").build(),
+ PlaybackException.ERROR_CODE_IO_UNSPECIFIED,
+ HttpDataSource.HttpDataSourceException.TYPE_READ
+ )
+
+ assertThat(policy.maxAttempts(error, playbackStarted = true)).isEqualTo(1)
+ }
+
@Test
fun `progressive network timeouts after playback start retry 10 times`() {
val error = SocketTimeoutException("timed out")