Skip to content

[bug] Android TV playback loops forever: server sends 5.1 audio the device can't play through its speakers #579

Closed

Description

@CoffeeKnyte

What happens

Playback on Android TV can get stuck in a permanent restart loop: the show never starts, the spinner never ends, and the app quietly retries forever.

The cause is a mismatch about audio channels.

When a video has 5.1 surround audio, the server re-encodes that audio to AAC 5.1 and sends it to the client. It decides to do this based purely on what's in the source file — it never asks the client whether the client can actually play 5.1.

The client, for its part, tells the server two things that sound reassuring:

  • "I support the AAC audio codec" — true, it can decode it.
  • "I support up to 8 channels" — also true, but only for passthrough, meaning audio it forwards untouched to an AV receiver over HDMI.

What the client never says is how many channels it can actually render itself, through its own speakers, after decoding. There is no field in the protocol for it.

So the 5.1 audio arrives, decodes perfectly, and then fails at the very last step — when it's handed to the speakers. The device can't output 6 channels, the player errors out, and playback dies before the first frame.

What it looks like

From the viewer's side: the episode never starts. Just a spinner, indefinitely.

From the server's side, this cycle repeats roughly every 10 seconds, indefinitely:

  1. Client starts playback — server says OK and begins transcoding with 5.1 audio.
  2. Client downloads the playlist and about 4 seconds of video. All succeeds.
  3. Client tries to play it, and the audio fails at the speaker-output stage.
  4. Client asks the server for a different plan.
  5. Server has no alternative to offer, so it gives up and says "no route available."
  6. Client tears the session down and starts over from scratch — getting the exact same plan again.

The playhead never moves. A healthy session downloads segments in order, moving forward through the episode; an affected session downloads the same two segments over and over, then dies and is replaced by a brand-new session. Every iteration starts a fresh transcode.

The error the client reports:

ERROR_CODE_AUDIO_TRACK_INIT_FAILED   (ExoPlayer error 5001)

That error comes from Android's AudioTrack — the audio output stage, not the decoder. The audio was decoded correctly. It just couldn't be delivered.

Reproduced with Silo Android TV. Source audio: EAC3, 6 channels, 5.1(side).

Why it never gives up

There's a second, independent defect that turns a single failure into an infinite loop.

The server does remember which plan just failed, so it won't immediately re-offer it. But that memory is attached to the playback session — and the client's way of recovering is to delete the session and start a new one. Deleting the session throws away the memory of what just failed.

So every attempt looks like a first attempt to both sides. Nothing ever accumulates enough evidence to back off, and the loop runs until the user gives up.

Possible solutions

A. The Android client downmixes to stereo itself — recommended

Give the Android player the ability to downmix multichannel audio to stereo when its output can't render all the channels, instead of failing outright.

This is what silo-apple already does by default: on tvOS/iOS, the audio stack automatically downmixes multichannel audio to whatever the output actually supports, so the same 5.1 plan simply plays. Android's AudioTrack instead hard-fails when it's handed a channel layout it can't render.

Recommended because it:

  • brings Android in line with the behavior Apple clients already have,
  • preserves real surround on devices and receivers that genuinely support it,
  • needs no protocol change,
  • and is robust no matter what the server decides to send.

This one lands in silo-android, so it needs a companion issue there.

B. The client advertises its real output channel count

Add a capability field for maximum output channels after decoding, distinct from the existing audio_passthrough.max_channels (which describes bitstream forwarding to a receiver, not the device's own rendering). The planner would then pick the channel count the client can actually play.

This is the most correct long-term fix, and it's additive, so it fits the v1 rules. It likely wants a [v1] capability proposal against #149 while that window is open. It does require both a server change and a client release before it takes effect.

C. The server downmixes to stereo whenever it isn't sure

Flip the server's default: send stereo unless the client has positively declared it can output more.

This is the safety net. It's server-only and ships without waiting on any client release, which makes it the fastest way to stop the loop. The cost is losing surround on devices that genuinely support it, until B exists to tell the server otherwise.

A and C aren't mutually exclusive — C protects clients that haven't been updated, while A fixes the client properly.

Technical detail

Where the channel count is chosen — internal/playback/plan_v3.go:495-500:

targetAudioChannels := 2
audioLayout := "stereo"
if source.AudioChannels >= 6 {
    targetAudioChannels = 6
    audioLayout = "5.1"
}

internal/playback/transcode.go:731-734 then emits -ac 6 -b:a 384k. The stereo branch immediately below it (-ac 2 -b:a 192k) is correct and works — it's just unreachable for any 5.1 source, for any client.

The comment justifying this is where the reasoning goes wrong:

// Preserve surround from multichannel sources when the planner asked for it (AAC 5.1 decodes universally in Media3)

That conflates decode with output. Media3 does decode AAC 5.1 nearly everywhere, and the plan's ValidatedClaims: ["media3_audio_decode"] is genuinely satisfied. Output capability is never modeled at all.

What the client actually sends:

codecs_audio:        ["aac", "flac", "mp3", "opus", "vorbis", "ac3", "eac3"]
passthrough_codecs:  ["ac3", "eac3", "eac3_joc", "dts", "dts_hd", "ac4"]   ← no aac
max_channels:        8
spatializer_enabled: false

This is all accurate. AAC is decodable and correctly absent from passthrough. max_channels: 8 sits under audio_passthrough and refers to compressed bitstream forwarding. ClientCodecCapabilitiesV3 (internal/playback/protocol_v3.go) has no field for post-decode output channels, and plan_v3.go never reads AudioPassthrough anyway.

Why replanning can't rescue it — the candidate walk in internal/playback/decision/service.go varies file versions. The failing dimension is channel count, which the walk cannot vary, so every candidate classifies ClassUnusable (service.go:186) and adaptation_exhausted is structural rather than incidental.

Why the loop never backs off — internal/api/handlers/playback_v3.go:1268-1284 accumulates attemptedKeys so a failed route isn't re-selected, deliberately, per the comment at :1276-1279. But that list is session-scoped and the client's recovery is to DELETE the session. The guard is session-scoped; the loop is session-crossing.

A note on status codes — a terminal replan returns HTTP 200 (:1041-1047, :1309-1310, written at :1085), so the failure carries no status-code signal.

Scope — this is specific to the protocol-v3 planning path. The legacy transcode sites (playback.go:2745, :3419, :3461) never set TargetAudioChannels, so it defaults to 0 and falls through to stereo. Only the v3 transports (playback_v3.go:724 local, :781 remote node) propagate a 6.

Observability

Nothing surfaces this today. The whole cycle logs no level=ERROR, and every HTTP status in it is a success code. All the evidence lives in playback_route_events.diagnostics, which nothing alerts on:

select received_at, event, jsonb_pretty(diagnostics)
from playback_route_events
where user_id = <id> and event in ('plan_failed','terminal')
order by received_at desc limit 5;

adaptation_exhausted is currently the dominant terminal reason. To a viewer it's just a spinner, which tends to get blamed on the file, the network, or the TV — so it's unlikely to arrive as a bug report with an error code attached.

This is not a regression from the recent protocol-v3 decision-service work; route events show it predating those commits by several weeks, and bisecting them left the restart rate unchanged.


Investigated with AI assistance (Claude Code). Findings verified against a running deployment: route-event diagnostics, ffmpeg argv, ffprobe of the source stream, and a bisect across the recent decision-service commits.

Activity

  1. added
    bug
    on Aug 10, 2026
  2. changed the title [-][bug] Planner forces AAC 5.1 from source channel count alone, looping playback forever on clients that cannot output 6-channel PCM[/-] [+][bug] Android TV playback loops forever: server sends 5.1 audio the device can't play through its speakers[/+] on Aug 10, 2026
  3. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
  4. added theissue type on Sep 20, 2026
  5. removed
    bug
    on Sep 20, 2026
  6. CoffeeKnyte commented on Oct 28, 2026

    @CoffeeKnyte
    ContributorAuthor

    Closing: the audio half of this is fixed on main (564b906).

    On one production server, Silo Android TV AUDIO_TRACK_INIT failures dropped from 53 in the 21 days before #1938 to 6 in the 9.5 days after.

    Two parts of this issue are not done:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions