The connection dropping: Orbit says so, keeps trying, and never marks the film unplayable (1.0 RC3-12, build 54)
release-gate / verify (push) Successful in 9m0s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m6s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m43s

Paul, 16 November 2026: the living room box's Wi-Fi failed during The Lost Boys on After Dark. Orbit marked the film as
one that won't play (so it would no longer be booked) and then said the server wasn't answering and that nothing was
wrong with the TV. Now a network or timeout error during playback says the connection dropped and retries every 15
seconds at the programme's current point; a failed tune says 'this TV has lost its connection' when Android finds no
working connection, and no longer says nothing is wrong with the TV otherwise. Films noted unplayable only for the
connection in earlier builds are given another go, once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 14:37:45 +00:00
co-authored by Claude Opus 5.5
parent 5b5b613b6b
commit 9d1c44fadc
5 changed files with 78 additions and 4 deletions
@@ -477,6 +477,19 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
delay(60 * 60_000L)
}
}
// Files noted as unplayable only because the connection failed (before 1.0 RC3-12) are given another go, once.
LaunchedEffect(session) {
val active = session ?: return@LaunchedEffect
withContext(Dispatchers.IO) { runCatching {
val log = scheduleStore.unplayable()
val lost = log.all().filterValues { it.optString("reason") == unplayableReason("IO_NETWORK_CONNECTION_FAILED") }.keys
if (lost.isNotEmpty()) {
scheduleStore.saveFailed(active.accountId, scheduleStore.loadFailed(active.accountId) - lost)
lost.forEach(log::remove)
android.util.Log.i("OrbitSchedule", "unplayable cleared=${lost.size} reason=connection")
}
} }
}
// The library read now, when asked for from adb ([CatalogueNow]); off the main thread, one at a time.
LaunchedEffect(session) {
val active = session ?: return@LaunchedEffect
@@ -37,6 +37,13 @@ import kotlinx.coroutines.withContext
/** A decoder fault normally repeats on the same file, so one more try is enough. */
private const val MAX_PLAYER_RETRIES = 1
internal const val CONNECTION_RETRY_MS = 15_000L
internal const val CONNECTION_LOST = "The connection to your server dropped. Orbit tries again every 15 seconds and picks the programme up where it is now."
/** A player error that's the connection's, not the file's: the network failing or timing out. */
internal fun isConnectionError(code: Int) = code == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED ||
code == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT || code == PlaybackException.ERROR_CODE_TIMEOUT ||
code == PlaybackException.ERROR_CODE_IO_UNSPECIFIED
/**
* The box's audio clock can go wrong deep into a long film (seen 3 November on Godzilla's TrueHD passthrough, about
@@ -95,6 +102,9 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
fun showInfo() { infoVisible = true; lastInteraction = SystemClock.elapsedRealtime() }
var handedBack by remember { mutableStateOf(false) }
var playerRetries by remember { mutableIntStateOf(0) }
// The connection dropping isn't the programme's fault (16 November 2026: The Lost Boys was marked unplayable when the
// living room box's Wi-Fi failed): say so, keep trying, and never note the file as one that won't play.
var connectionWaits by remember { mutableIntStateOf(0) }
var audioRetries by remember { mutableIntStateOf(0) }
var audioClockResets by remember { mutableIntStateOf(0) }
var audioChosen by remember { mutableStateOf(false) }
@@ -195,6 +205,14 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
player.prepare()
}
}
LaunchedEffect(connectionWaits) {
if (connectionWaits > 0 && scheduled != null) {
delay(CONNECTION_RETRY_MS)
failure = null
player.seekTo(scheduled.programme.offsetAt(scheduled.nowMs()))
player.prepare()
}
}
LaunchedEffect(numberEntry) { if (numberEntry != null) { delay(10_000); numberEntry = null; numberProblem = null } }
// Closes by itself, so a stray press doesn't leave it over the programme.
LaunchedEffect(trackMenu, trackCursor) { if (trackMenu != null) { delay(10_000); trackMenu = null } }
@@ -245,6 +263,12 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
audioRetries++
return
}
if (scheduled != null && isConnectionError(error.errorCode)) {
failure = if (tvOnline(context)) CONNECTION_LOST else TV_OFFLINE
ready = false
connectionWaits++
return
}
// A decoder can also be taken away by a quick channel change, so a channel tries once more before giving up.
if (scheduled != null && playerRetries < MAX_PLAYER_RETRIES) {
ready = false
@@ -119,6 +119,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
neighbours.forEach { TuneAhead.warm(session, it) }
}
val prepareMutex = remember(channel) { Mutex() }
val tuneContext = androidx.compose.ui.platform.LocalContext.current
val handedNow = handed?.takeIf { it.available && it.channelNumber == channel.number }
var prepared by remember(channel) { mutableStateOf(handedNow?.plan) }
var preparedSlot by remember(channel) { mutableStateOf(handedNow?.startMs) }
@@ -131,7 +132,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
// Waiting on a slow server (1.0 RC3): after a few seconds the tuning screen says so; when it doesn't answer at all, Orbit
// tries again every 30 seconds by itself.
var serverRetry by remember(channel) { mutableIntStateOf(0) }
LaunchedEffect(serverRetry) { if (serverRetry > 0) { delay(30_000); if (problem == SERVER_NOT_ANSWERING) { problem = null; retryAttempt++ } } }
LaunchedEffect(serverRetry) { if (serverRetry > 0) { delay(30_000); if (problem == SERVER_NOT_ANSWERING || problem == TV_OFFLINE) { problem = null; retryAttempt++ } } }
var waitingOnServer by remember(channel, current.startMs) { mutableStateOf(false) }
LaunchedEffect(channel, current.startMs, retryAttempt) { waitingOnServer = false; delay(8_000); waitingOnServer = true }
// Kids on a channel during a grown-up takeover: it's asleep, and nothing of it is opened.
@@ -167,7 +168,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
} catch (cancelled: CancellationException) { throw cancelled }
// The server not answering at all (13 November 2026: Emby froze for six minutes during its scan) isn't this programme's
// fault: say so plainly, and try again by itself every 30 seconds rather than give the slot up.
catch (failure: ServerNotAnswering) { problem = SERVER_NOT_ANSWERING; serverRetry++ }
catch (failure: ServerNotAnswering) { problem = if (tvOnline(tuneContext)) SERVER_NOT_ANSWERING else TV_OFFLINE; serverRetry++ }
catch (failure: EmbyCheckException) { problem = if (channel is ScheduledChannel) "This programme isn't available right now. Orbit moves on at ${clock(current.endMs)}." else failure.message }
catch (_: Exception) { problem = if (channel is ScheduledChannel) "This programme isn't available right now. Orbit moves on at ${clock(current.endMs)}." else "This scheduled programme could not be opened. Return to the guide and try again." }
}
@@ -284,7 +285,15 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
} }
}
internal const val SERVER_NOT_ANSWERING = "Your server isn't answering right now. Orbit tries again every 30 seconds; nothing is wrong with this TV."
internal const val SERVER_NOT_ANSWERING = "Orbit can't reach your server right now. It tries again every 30 seconds. If other apps on this TV are slow too, it's this TV's connection."
/** When the TV itself has no working connection (16 November 2026: the living room box's Wi-Fi dropped, and Orbit blamed the server). */
internal const val TV_OFFLINE = "This TV has lost its internet connection. Orbit tries again every 30 seconds and carries on once it's back."
/** Whether this TV has a connection Android has checked reaches the internet. */
internal fun tvOnline(context: android.content.Context): Boolean = runCatching {
val cm = context.getSystemService(android.net.ConnectivityManager::class.java)
cm.getNetworkCapabilities(cm.activeNetwork)?.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED) == true
}.getOrDefault(true)
@Composable
internal fun ClassicTuningNumber(number: Int, modifier: Modifier = Modifier) {