Skip to content

feat(playback): lower Auto quality when playback keeps buffering, and test connection speed - #2699

Merged
Quick104 merged 259 commits into
mainfrom
feat/buffering-quality
Oct 23, 2026
Merged

Quick104 merged 259 commits into
mainfrom
feat/buffering-quality

Conversation

@Quick104

@Quick104 Quick104 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #637
Validation tasks: none of the passed cases are affected; no task this reaches has a recorded result yet. Changes cases not yet run: #1217 C1 (speed tests add per-account and per-server limits that answer 429), #1220 C2, #1221 C1 and #1222 C1–C2 (the new playback setting resolves and shows like the others, the speed schedule restarts on a profile switch, and the admin device page gains a Connections section), and #197, #199, #1250 C5 and #1252 C3 and C5 (Auto lowers quality after repeated buffering, Auto transcodes are sized to the connection, the quality menu gains two low rungs, and the web player shows Reconnecting during an outage). Client cases are listed on Silo-Server/silo-apple#842 and Silo-Server/silo-android#636.

When a stream keeps buffering, Silo clients mostly keep buffering. The web player lowers Auto quality and forgets the limit after 30 minutes. Android notices only a start that stalls for 20 seconds, and Apple clients don't notice at all. On an onn 4K Pro set to Auto, a 63 Mbps 4K remux buffered through an entire film over a 40–80 Mbps link. Android sent no bandwidth estimate, the one failure replan came back at the same bitrate, and the title's 31.6 Mbps 1080p version, which would have played, was never tried. The server kept no record of the rebuffering, so nobody could tell how often it happens.

This PR gives every client one behavior, defined in a shared spec, and the server what it needs to support it. On Auto, a client that sees repeated buffering lowers quality and offers Restore quality, or asks first if the viewer chose that. The server remembers the lower limit for that device on that network for 24 hours, and a Test speed result above the limit lifts it. A connection speed test gives Auto a measured budget before the first stall, and the server plans Auto under the connection's stored reading when a request carries no estimate.

It is one PR because it is one design. The speed test is how Auto gets its budget, and the learned limit and the reading feed the same budget. The commits interleave the spec, the controller and the speed test, so splitting them would mean rewriting history that the Apple and Android branches cite.

Approach

The spec is docs/design/2026-10-17-buffering-quality.md. Conformance vectors in docs/design/schemas/buffering-quality/v1/vectors.json pin the stall detector, the budget arithmetic and the speed test measurement, and the web, Apple and Android tests replay them: 66 controller cases, 13 speed test cases and 9 budget cases. The spec records a maintainer's rulings on the points where the three clients differed, and a second set made on 2026-10-22 after testing on an Apple TV, an Android TV emulator, a Pixel phone and the web. Where the two sets differ, the later rulings apply.

Lowering quality:

  • A new profile setting, Lower quality when buffering, chooses Automatically (the default), Ask first or Never. A quality the viewer picked is never lowered without asking. A server without the setting hides the row and clients run Automatically; clients check for the setting's key, not a manifest revision.
  • Only buffering caused by a slow link counts toward lowering. Pauses, seeks, source reloads, a browser decoder restart and outages don't count. Playback is in an outage when a media request errors or cannot connect, the device is offline, or the player waits while none of the plan's media requests has received data for 4 seconds on progressive delivery, or 15 seconds on HLS, where the server can hold a segment request while it produces the segment. A request that keeps receiving data is never failing, however slowly, and a player's own timeouts no longer decide it. Subtitle requests count neither way. An outage ends only when the plan's media arrives again or playback runs, and it never ends playback: the client sends no failure recovery during it and resends a replan that got no answer.
  • A wait with plenty of media buffered is the device falling behind, not the network: more than 5 seconds in a browser, or twice the player's resume amount on Android's Media3. It never lowers quality.
  • A start that never plays is timed from its plan's adoption. A plan adopted before any plan of the attempt has played continues that start's wait, and a replacement for a source that has played is a source reload.
  • Before any plan of the attempt has played, nothing lowers without evidence that the plan's media arrived more slowly than its delivered bitrate. With that evidence, a start that misses its deadline on Auto in Automatically lowers instead of failing at the same quality. In every other case (an outage, a renderer wait, Ask first, Never, a quality the viewer picked, Watch Party, nothing lower) the start keeps the failure path, as does a deadline lowering that is refused or never adopted. On the web, direct play now has the same start deadline as HLS.
  • After a prompt times out, the next can show no sooner than two minutes after the first appeared.
  • Lower quality steps from the rung the plan names in active_quality (plan_active_quality_v1), capped at the delivered bitrate, or from the delivered bitrate when the plan names none.
  • A quality or version the viewer picks hides any pill as it is sent and changes the controller's state only when its plan is adopted. Nothing prompts or lowers while the pick is pending, and a refused pick changes nothing. A version the viewer picked is sent with allow_alternate_versions: false, so Auto never swaps it.
  • In a Watch Party room the client tracks buffering but neither prompts nor lowers.
  • A replan caused by buffering carries an observed_rebuffer estimate and, when the client measured it, observed_throughput_kbps: what the plan that kept buffering received. The server plans with the lower of the two and keeps it as a learned limit per device and network for 24 hours from the last observation. Viewers can reset it in Settings, admins can clear it on the device page, and a Test speed result above it clears it. In Never mode Settings hides the limit, which that mode ignores. A lowering is refused, not queued, while another replan is in flight, and its estimate is not kept.

Planning Auto under a budget (a request's estimate, the stored reading, a lowering or a learned limit):

  • An Auto start or replan from a buffering_quality_v1 client that carries no estimate, such as a start in the first seconds or a failure recovery, is planned under the connection's current reading. This records nothing, and a seek replan that replays the stored request is unchanged.
  • Auto first tries a lower-bitrate version of the same edition that plays without video encoding: of those that fit, one that keeps the source's dynamic range, then the highest bitrate. Then it tries a transcode.
  • An Auto transcode targets its budget, up to its class's highest menu rung (40 Mbps for 4K, 10 Mbps for 1080p), where it used a fixed 20 or 6 Mbps. No Auto transcode targets more than that rung, which stops failure recovery planning a 4K transcode at the source's 100+ Mbps. The exception is the local network when neither an estimate nor a cap applies, where conversions keep their old bitrate. At low budgets video and audio fit together, in stereo once the audio share drops below 192 kbps.
  • The /api/v2 quality menu gains 480p Low (800 kbps) and 360p (300 kbps), so Auto can step down until a stream fits a 500 kbps link. The frozen /api/v1 menu does not show them.
  • If nothing lower fits, the plan reports quality_reduction_unavailable. A plan reports bandwidth_limit only when the limit lowered it: the server plans the start or replan again without the limit, with the same version step and reading, and keeps the field only if that plan sends more.
  • Plan summaries report stall counts, stall time, the buffering action and, where the client measured it, throughput, so the server can count rebuffering. The web sends the last one as the page closes, and a page restored from the back-forward cache starts a new adoption of the plan it was playing. A summary carries no throughput sample when the network changed during the plan or when it is sent at a later launch. The frozen /api/v1 route still rejects plan_summary.

Connection speed test:

  • The test runs on the media path, so it measures the route playback uses: through the media proxy when routing sends media there.
  • The automatic quick test downloads up to 100 MB and stops once it proves the highest bitrate the server would plan for this profile, plus 25%, and at least 100 kbps. It runs only when the server holds no current reading for the device and network. Test speed in Settings runs a 1 GB, 10-second accurate test, and replaces an automatic test that is running.
  • No test runs on cellular or with Data Saver on (Settings hides Test speed there), and no automatic test runs while any media plays or loads, theme music included. Phones and tablets that cannot report their link type run no automatic test either, which covers every browser on iOS and iPadOS and Firefox on Android. A 429 holds automatic tests until its Retry-After.
  • Readings are kept per device and network for 7 days by default; administrators can set 1–30 days or turn automatic tests off. Throughput measured during playback is kept as a lower bound, so a fast link that never ran a test still gets a budget, and the reading is the higher of the two. A Test speed result replaces that playback sample, so a fresh, lower test is not outvoted by an older sample. A device's connection rows go with its last registration.
  • The server allows 4 probes at once per node and 2 GB per account per 10 minutes. Beyond either limit it answers 429 with Retry-After.
  • Clients read the stored reading as soon as a profile is active and they are online, and send it on starts. On the web, a tab back within a minute of being hidden sends nothing, the same minute the app keeps its events socket open through a tab switch. A sign-out or a different account discards the kept reading.

Subtitle extracts. On Apple TV, a transcode with an embedded text subtitle selected waited for the whole track, which the server extracts from the entire source file: about 42 seconds on a 4K remux, long enough to keep lowered plans from starting. When a start gave up, the server discarded its extract and the retry began again, and each of the player's requests for the track ran its own extract. The Apple PR stops the start from waiting; two server changes help every client that fetches a whole embedded track:

  • When the viewer leaves a full-track extract early (a start that gave up, a replan or a seek reload), the extract finishes into the subtitle cache if a background slot is free, so the retry is a cache hit.
  • Concurrent requests for the same track on one node share one extract instead of each running ffmpeg over the whole file. A slow reader holds up only itself. The cache is per node, so another node extracts on its own, as before.

The web app gets the buffering prompt and undo pill, the setting and learned-limit row, a Connection group in Settings → Playback, the automatic speed-test settings in admin Playback settings, a Connections section on the admin device page, and a Reconnecting indicator while playback waits through an outage. Settings and the device page show rates rounded down, in Mbps from 1 Mbps and in kbps below.

Multi-repo checklist:

  • API contract: every change is additive to /api/v2. New endpoints are GET /api/v2/playback/connection, DELETE /api/v2/playback/connection/learned-limit, POST /api/v2/playback/bandwidth-probe/results and the admin learned-limit DELETE. Capabilities, start, replan, plan, route events, probe results (manual) and the admin device detail gain optional fields, and bandwidth_probe_url is declared as a URI. The connection endpoints' times are v2 instants, and the observations that can be absent are declared nullable. Clients detect the features through buffering_quality_v1 and connection_speed_v1, and the server records and applies learned limits only on requests that carry buffering_quality_v1. A learned-limit reset that names no device is refused. /api/v1 routes are unchanged.
  • jellycompat: Jellyfin clients choose their own bitrate with BitrateTest, which keeps Jellyfin's 100 MB limit while the native probe allows 1 GB. Nothing else changes there.
  • Docs: the spec and vectors, docs/playback-api.md, docs/architecture/playback-protocol-v3.md, and the playback v3 schemas and fixtures. The user manual change is Document automatic quality lowering and learned connection limits siloserver.org#231.
  • Clients: the Apple and Android PRs implement the same spec. Apple: feat(playback): lower quality when playback keeps buffering silo-apple#842. Android: feat(playback): lower Auto quality when playback keeps buffering, and test connection speed silo-android#636.

Validation

The checks ran on 4dbe92c0a, which includes main (the branch is not behind it). The device runs used earlier builds of the branch, before the subtitle and review fixes of 2026-10-23.

  • CI: every check passes.
  • Go: make test-go passes on Linux (186 packages). Build, gofmt, vet, make lint-changed and make lint-router-recovery are clean.
  • Database contract tests: all 338 pins pass against a fresh database, which applies every migration.
  • Web: lint, format check, build, bundle budget and make test-web pass (838 files, 6,702 tests).
  • Contracts and hygiene: every verify-* target in CONTRIBUTING passes. verify-apiv2-contract reports only additive changes.
  • The web tests replay all 66 controller vectors, 13 speed test cases and 9 budget cases; the Apple and Android PRs report their own replays. Tests cover the probe limits, the speed test target, the connection store, the speed test schedule, the throughput sample, the version step and encode budgets, and the shared subtitle extract (a viewer that leaves, concurrent viewers, a temp file that fails mid-fill).
  • On a dev deployment that included this branch, with the link shaped:
    • An Apple TV on a 22 Mbps link, subtitles off, lowered once from a 97 Mbps 4K direct play, stored a limit at 93% of the link and played a 10 Mbps transcode with no further stalls. At 4 Mbps, a 44.7 Mbps start lowered once to a 2.4 Mbps transcode and played with no further stalls. On a 780 kbps link, a 44.7 Mbps start spent about 10 minutes opening the file, then lowered to a 363 kbps 480p plan that played. A Test speed cleared a learned limit and replaced the playback sample.
    • The same 22 Mbps run with an embedded subtitle on lowered once, but the lowered transcode then failed to start while the server extracted the subtitle. The subtitle changes above and the Apple PR's HLS subtitle rendition address this; that run has not been repeated on the device.
    • The web player in Chromium lowered once at 12 Mbps to a limit of 11.5 Mbps, lowered a slow start at 3 Mbps without losing the resume position, showed Reconnecting through 10- and 25-second cuts without lowering, and kept a picked 4K version.
    • A tvOS simulator's cold embedded-subtitle request and its refetch after a forced cut were served by one server extract.
  • Not run on a device: a 500 kbps link, and the server's reading fill on a start that carries no estimate. Tests cover both.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/buffering-quality/

Risks

  • Auto now lowers quality by default when playback keeps buffering. Viewers can switch the setting to Ask first or Never, reset the learned limit, or run Test speed.
  • A Wi-Fi dropout shorter than 15 seconds during an HLS plan can still count as buffering and leave a learned limit. The limit lasts 24 hours, and Test speed lifts it.
  • Auto transcodes on a fast link now run at up to 40 Mbps for 4K and 10 Mbps for 1080p, where they used 20 and 6 Mbps, which costs more node egress.
  • Browsers on phones and tablets that cannot report their link type never run the automatic test, because it could spend mobile data without the viewer knowing. On iOS and iPadOS the web app therefore starts without a measured budget until the viewer runs Test speed or a playback leaves a throughput sample.
  • Speed tests cost egress: up to 100 MB per automatic test, and 1 GB per accurate test. The 2 GB per 10 minutes budget is shared by every device on an account, so a household that runs several accurate tests at once can get 429 until the window frees. Administrators can turn automatic tests off.
  • A subtitle extract whose viewer leaves now keeps running in a background slot, up to the same two slots and 30-minute limit as other background warms.
  • Five Goose migrations add the connection store, let route events carry plan_summary, and drop the trigger that deleted connection rows with a device in favour of a helper on every deletion path in both user stores. The widened route-event check is added NOT VALID and validated in its own migration, so the scan of retained route events does not block playback writes. Two of the migrations are dated before main's newest; the runner allows out-of-order migrations, so a database already at main applies them.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.

AI Disclosure

  • Harness: Claude Code under T3 Code; OpenAI Codex CLI
  • Tool(s): Claude Code; OpenAI Codex CLI
  • Model(s): claude-opus-5-5 (Claude Opus 5.5); gpt-6-astra
  • Involvement: Fully AI-generated. A maintainer made the product decisions. Claude Opus 5.5 wrote, reviewed and fixed the code; gpt-6-astra in Codex CLI built the first phase 1 and 2 commits.
  • Adversarial review: read-only Claude Opus 5.5 reviewer agents checked the server and web diffs against the spec in two rounds, before and after the speed test redesign. The first round led to fixes in af3a79d, 7666da5, 6c4c63a, 4210426, f6fbabe, 5cb0a7f and 50f32d3, among them the admin cap on the connection budget and a write deadline for the media proxy's probe. The second found that the speed test target counted files the profile cannot play, a canceled read cached no target, the web read the connection before a profile was active, a reading under 100 kbps could be kept and then rejected by every start, and four smaller web bugs; c71af46 through 1865927 fix them, with regression tests. A third round compared the web, Apple and Android clients with each other and with the spec. A maintainer ruled on the 46 points where they disagreed or the spec said nothing, 4ab2b8e and 5a7adf5 record the rulings, and bd604be through 236ab54 bring the web and server in line. A reviewer then checked the speed test schedule changes and found five more bugs, which cc0227f fixes: a refused start held Test speed off for a minute, a read in flight across a network change kept the old network's reading, turning Data Saver off started no read, a saved result whose read-back failed was reported as a failure, and a replan's reload did not hold tests off. A server and web audit then simplified the code without changing its behaviour (about 330 lines fewer) and fixed what it found, each fix with a test that fails without it: /api/v1 accepted plan_summary again; the speed test target read the file's bitrate rather than the planned one; a start or replan whose lower version compatibility alone chose was labelled limited; probe proxies were picked without checking they serve speed tests; a failed target read could replace a good cached one; connection rows outlived devices in one race and in the SQLite store; a summary was lost when its delivery lookup failed or ran slow; and six web schedule and pick bugs. Left as follow-ups: connection rows for client-chosen device IDs, which expire after 30 days; a playback sample filed under the network that reports it; and probe slots that a stalled reader holds for up to two minutes. Comparing with the Apple PR later found that a Restore pressed while a start was in flight was lost; 81dca25 fixes it with a regression test. After the 2026-10-22 device testing, reviewer agents checked the server and web fixes; the server findings (a plan labelled limited that the limit did not lower, the first fitting version picked rather than the best, the new rungs on the /api/v1 menu, local conversions losing their bitrate, 6-channel AAC at low budgets, and the speed test target's refresh) are fixed in 1d55fba through c39654d, and the web findings in 3febf39 through ec9a4db.

🤖 Generated with Claude Code

Note

Lower Auto playback quality during buffering and add server-backed connection speed tests

  • Adds a buffering-quality controller that detects stalls, asks the viewer or lowers Auto quality automatically, and shows an undo pill with Restore quality. The mode (never/ask/always) is a profile setting with a remembered fallback.
  • Adds server-backed bandwidth probes: clients measure streaming speed, report results, and the server stores per-device connection observations and learned limits. Plans can carry an observed-rebuffer bandwidth limit, and startup guards now apply to all transports.
  • Adds quality rungs 480p Low and 360p, an admin connection view with learned-limit reset, playback-connection settings, and a shared bandwidth-probe limiter (per-account/node concurrency, 2 GB ten-minute byte budget, up to 1 GB probe size).
  • Replaces per-request subtitle teeing with shared progressive fills so concurrent viewers join one extraction, and a fill can continue after its last viewer leaves when a warm slot is free.
  • Behavioral changes: removing a device deletes its playback connection rows only after the last registration is gone; metered connections no longer send a cached client estimate; frozen v1 playback responses drop the new low rungs; capability reads now issue one extra request at boot; probe redirects can return 307 to a media proxy or 503 when no proxy serves probes. createStallTracker and downshiftEstimateKbps exports were removed from useAutoQualityDownshift.ts.

Macroscope summarized 003c9d8.

Quick104 and others added 30 commits October 17, 2026 20:56
…ules

A prompt timeout or a rearm restarts the trigger's stall timing, and the
controller did that by ending the stall, so one long stall reached
plan_summary as two shorter ones. The trigger's timing and the summary's
now run separately. A seek within the buffer no longer stops played_ms,
because no playing event follows it.

The controller also loses its magic numbers: the spec's constants are
named and documented, event and action names are typed, and the
step-down estimate lives in one function. The vector runner reads the
summaries each plan reports instead of the controller's internal map,
and advances its clock one millisecond at a time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A seek-scoped replan replays the stored start request. Applying the learned
limit rewrites that request: its estimate becomes the limit, or a lower probe
estimate is marked observed_rebuffer so Auto still tries copy versions first.
Replaying it recorded that estimate again, which renewed the limit's seven
days on every seek recovery and could store a probe hint as the limit.

Only a request the client sent now records an observed estimate or clears the
limit. A replay still plans under the limit and honours a stored ignore.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`pnpm run build` runs `tsc -b`, which rejected the indexed reads of the
captured summaries as possibly undefined, so the web build failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A replan whose connection-store read failed returned a terminal with a new
reason, connection_store_unavailable, that no client or document knows and
that dropped the underlying error. Use the existing retryable internal_error
and keep the cause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The connection store, seek-replay and replaced-plan summary tests need
Postgres, so make test-go skips them and no CI job ran them. List them as
database contracts so the Go DB pins job runs them against a migrated
database and fails if they skip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The buffering prompt and undo pill could show beside a Skip Recap,
Skip Credits or Skip Preview pill, though the spec gives every segment
skip priority. They also rendered in the minimized player, where their
keys are not handled, and sat at the bottom centre over subtitles in a
style no other player control uses.

The pills now wait behind any segment skip, as they already did behind
intro skip and Next Up. They render in the notice slot the spec names,
stacked with any notice there, as a notice card whose actions are the
intro pill's capsules, with the countdown filling the primary action.
They render only in the full player. Back reaches them from anywhere,
as it does the intro pill, and an answer from the keyboard moves focus
to the transport. Focus is taken only as a pill appears, under the
intro pill's rule. The hook reports a deadline instead of re-rendering
the player every 100 ms while a pill shows. Display-only notices no
longer carry an empty message line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The frozen v1 start and replan ignored bandwidth_estimate_source and
learned_limit as unknown fields. The branch validated them before stripping
them for v1, so a v1 request carrying either without buffering_quality_v1
now failed with 400, and a v1 replan could still run the observed-budget
version search. Drop both fields on v1 before validation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Playback does not wait for effective settings, and the watch page
filled an unknown buffering mode with `never`. A start made before the
settings arrived then sent `learned_limit: "ignore"`, so a viewer on the
default `always` played the very title the server had learned to limit
at full quality and stalled again.

The mode is now null until known, as the intro skip mode is. The start
then omits `learned_limit`, the spec's default, and the controller only
watches until the real mode arrives. A server without the setting still
gets automatic lowering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bandwidth_probe_url was built from r.Host. Behind a TLS-terminating reverse
proxy that is the internal host the proxy dialed, so clients were told to
probe an address they cannot reach. Build it with RequestBaseURL, which the
v2 listener already uses for absolute URLs and which honours the forwarded
host and scheme.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every replan first looked up the playback capabilities, which are cached
for 60 seconds and time out after 5. A replan sent to rescue a congested
link, the very case buffering lowering exists for, could fail on that
lookup before it was sent, and none failed this way before the branch.

The video player now passes the features its session's last decision
advertised, as the spec allows. Other callers still look the
capabilities up, but a failed lookup sends the replan without the
negotiated fields, which every server accepts, instead of failing it.
Tests now cover the gate in both directions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
plan_summary carried no `bandwidth_estimate_kbps`, one of the spec's
summary keys and one Android sends: the estimate the plan was requested
with. It is now recorded with each adoption's route identity. A second
summary for the same adoption, which a controller restart can produce,
was sent under the live plan's identity; it is now dropped, and the
unused plan-ID fallback is gone.

Tests now also pin `learned_limit: "ignore"` on start and replan in
Never mode, and its absence in Automatically and while the mode is
unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The learned-limit row sat in the phase-two Connection group, apart from
Lower quality when buffering, where the spec, Android and Apple put it.
It now follows that setting in the Quality group, and the Connection
group holds only the speed rows. Its date read "10/17/2026" and ignored
the date-format preference; it now reads "Oct 17", or "17 Oct", as the
spec says.

Test speed blamed playback for any failure, including a failed or
refused measurement. A probe that could not run now resolves to null,
and one that ran and measured nothing rejects, so the row says which
happened. A probe measured days ago read "measured 4320 minutes ago";
it now counts in hours and days. Rates use the web's bitrate formatter,
prose under the rows uses the settings text style without the stray
indent, and Reset is disabled while it runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ith v3 maintenance

The store packed every declaration and query onto single lines with no doc
comments, repeated the 7-day and 30-day lifetimes as SQL literals, and the
admin list judged expiry by the API clock while reads used the database
clock. Its retention loop ran as a second hourly goroutine with no timeout
beside StartV3Maintenance, and recordRouteEventV3 took the store as an
optional variadic argument.

Document the exported API, pass TTL and Retention to every query, judge
expiry in SQL everywhere, run Cleanup from StartV3Maintenance under its
30-second timeout, and pass the store explicitly. The admin view test now
checks that an unexpired limit is listed. Behaviour is otherwise unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mments

Acquire and Release kept the lower-case names they had before the limiter
moved into its own package, and NewLimiter had no comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The retired limit left a `link` field that nothing writes any more, the
checks that read it, comments that still described the limit, a test-only
wrapper around the probe, a second write of each scheduled result, and
two tests of behaviour that no longer exists. They are gone. The one
guard that matters stays: an entry an older build wrote after a stall
is not read as a probe result. It shares the probe's key and expires
within the 30-minute TTL, so no separate cleanup is needed.

A visibility change no longer starts a second probe beside a running one
in browsers without Web Locks. Coverage that went with the removed tests
is back: a refused localStorage write and a newer result from another tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y added case

The amendments made while answering client questions read as run-on notes:
slashes, nested parentheses and a list of suppression reasons inside a
sentence. Rewrite them in plain sentences without changing a rule, split the
conformance event list into a list, mention controllerInitiated, which one
case already uses, and replace the partial prose list of added cases with a
table naming all of them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After an automatic lowering, the client's next Auto replan for its own
reasons (a track change, seek or failure recovery) carried no estimate.
Without a learned limit, on a server without buffering_quality_v1, a request
without a device ID or one sending learned_limit ignore, Auto went back to
the source, which stalled and lowered again in a loop. Android hit this in
device testing.

The client now keeps the lowering's step-down estimate in memory for the
playback attempt and sends it on later Auto replans without
bandwidth_estimate_source. The next lowering replaces it; Restore quality,
a quality change the controller did not send, and a new start discard it.
The server records nothing for an estimate without a source, so these
replans neither learn a limit nor extend one.

The vectors gain three events, client_replan, quality_changed and
new_attempt, and five cases that pin the rule. Existing cases are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A client replan that repeats its kept estimate sends bandwidth_estimate_kbps
without a source. Check that Auto plans with the lower of that estimate and
the learned limit, and that the request neither records a limit nor extends
its seven days.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… API

The same buffering-quality section was pasted into both the protocol v3
architecture doc and the playback API doc. Keep the protocol rules, learned
limit identity and telemetry in the architecture doc, and the connection
endpoints, probe results and admin view in the API doc, each linking the
other. List the new operations, connection_speed_v1 and bandwidth_probe_url,
and describe the media-path probe, which the bandwidth-probe section still
said measured only the API path.

Also correct what the docs claimed: version search before transcoding runs
only on a start or quality_change replan that allows alternate versions, an
estimate without a source and seek replans record nothing, v1 ignores the
new fields, and a proxy-only policy with no probe proxy answers 503
dependency_unavailable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After an automatic lowering, the player's next Auto replan for its own
reasons, such as a track change, seek reanchor or failure recovery, sent
the cached probe result or nothing. Without a learned limit Auto then
went back to the source, stalled, and lowered again. The browser-local
observed limit this branch removed used to cover that on the web.

The controller now keeps the latest Auto lowering's step-down estimate,
replaces it with the next one, and drops it on Restore quality, a
quality change it did not send, and a new playback attempt. It reports
the estimate to the session, which sends it on its own later Auto
replans without bandwidth_estimate_source. A probe result is now
labelled `probe` where it is read, because the wire helper no longer
labels every unsourced estimate as one. The controller answers the
vectors' client_replan, quality_changed and new_attempt events, and all
37 cases pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fering budget

An output change returns the replan to the requested edition, but only a
quality change searched for a lower version. After Auto had lowered a 4K
HDR source without a tone-map route to its 1080p version, an output change
under the learned limit sent the 4K source back with
quality_reduction_unavailable, which stalled and lowered again.

Every replan that goes back to the requested edition now runs the same
version search before planning. Track changes stay on the mounted version.
A new handler test drives start, the lowering and the output change through
the native v2 service; before this change the lowering already played the
version, and the output change returned the source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ler stops

The controller reports its kept estimate to the session, and only the
controller discards it. When the controller stopped mid-attempt, as it does
while a Watch Together room is active, the session kept repeating the
estimate on its own Auto replans, and the next controller, which starts
without one, could never discard it: a later quality change left the
lowered estimate in place.

Stopping the controller now clears the session's copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…te changes

The scheduler treated every Network Information `change` event as a new
network: it dropped the cached probe result and scheduled another 40 MB
probe. Browsers also fire `change` when only their own downlink or RTT
estimate moves, so an idle tab could probe again and again, and a viewer's
later starts and replans lost the estimate they would have sent.

Only a change of connection type now counts as a new network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… limit

GET /api/v2/playback/connection computed auto_budget_kbps with the
administrator's stream bitrate cap read from a context value that only
start and replan set, so the cap was always zero. A remote viewer capped at
12 Mbps with a 48 Mbps probe was told Auto plays up to 38.4 Mbps.

Start and the connection endpoint now share one function that selects the
cap for the caller's network from the resolved access scope. A database
test pins the budget with no cap, a remote cap, and a local cap that does
not apply to a remote caller, and runs with the other buffering-quality
database contracts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The standalone proxy runs without a server write timeout, and its probe
handler wrote through a plain counting writer. A client that opened a probe
and stopped reading without closing the connection held the account's probe
slot, the node-wide slot and its goroutine until the proxy restarted; two
such connections locked the account out of speed tests, and sixteen
accounts would fill the node.

A probe response now has an absolute two-minute write deadline, the API
listener's write timeout, which the API-served probe already had. A test
stalls two probes and waits for a third to be admitted once they are reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
markLearnedLimit annotated the first planned result. The alternate-version
fallback and the progressive-remux escalation can replace that result
afterwards, and the replacement went out without bandwidth_limit although
the limit had lowered it. The output-change fallback to the playing edition
also restored a request captured before the learned limit rewrote its
estimate, so it planned without the limit.

The plan is now marked after every fallback, on start and replan, and the
fallback request carries the limited estimate.

A database test runs a lowering that records the limit, then an output
change with no estimate, and checks that the stored limit keeps it on the
lower version with bandwidth_limit set. It joins the buffering-quality
database contracts. The replan test also covers an output move reported as
a failure recovery classified output_route_changed, which is how Android
sends one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 and others added 5 commits October 22, 2026 19:55
…tion

The probe result's manual flag now also replaces the stored playback sample;
only the generated descriptions change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ails

A manual Test speed result now clears the server's playback sample, and
the web re-reads the connection afterwards, replacing what it keeps for
starts. When that read-back failed, the page kept the older, higher sample
and the next start sent it, outvoting the test, as on the Apple TV. Now a
failed read-back after Test speed drops the kept server readings, so starts
send no estimate and the server plans with its own reading (the test's
result) until the next look. Automatic tests keep today's behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The startup guard armed only for HLS plans. A start the element loads
itself (an original or a progressive remux) had no deadline, so a start
that never showed a frame sat on its spinner with no failure path, the
web form of the Apple TV start that stayed on "Loading" at 5 Mbps.

Every transport now gets the 60 s deadline, and a missed one goes
through the buffering controller as for HLS. The browser engine keeps
its own readiness deadline and stands the guard down when it attaches.
The guard drops the HLS prefix it no longer fits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A full-track embedded subtitle extract streams to the first viewer while
it fills the cache, and was discarded as soon as that viewer left. On a
large remux the whole-file demux takes about 40 s, and the viewer that
leaves is usually about to ask again: a start that gave up and retries,
or a replan or seek that reloads the item. Each retry then started the
demux over.

When the viewer goes, the extract now carries on into the cache in a
background warm slot, so the next request is a cache hit. With every
warm slot busy it stops and discards as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for a track

A player opening an embedded-track sidecar can send several requests for the
same URL at once. AetherEngine's AVIOReader sends a tail prefetch, a ranged
open, a one-byte range check, and then the unranged download. Only the first
request took the cache fill; the others each ran their own whole-file ffmpeg,
so a cold 4K remux was demuxed two or more times in parallel, and the
download the player kept was never the one filling the cache.

A full-track miss now starts one fill whose extract writes only to the
cache's temp file, in the background. Every request for the track while it
runs, the first included, streams that file as it grows and finishes from the
committed entry. A stalled client therefore holds up only itself. When the
last viewer leaves early, the extract keeps going in a warm slot (or stops
when none is free), as before. A fill that fails reports its error to its
viewers. If the temp file fails, a viewer runs its own extract and skips the
bytes it already sent. Background warms can be watched the same way. Text
batch fills, which write their files only at the end, cannot be watched, so
their concurrent requests still extract for themselves. The fills are per
process, so requests on other nodes extract as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread web/src/player/media-data-meter.ts Resolved
Quick104 and others added 6 commits October 23, 2026 14:25
Conflicts: main's cap class rule (#2643, a cap earns the tallest class whose
class bitrate fits, with no headroom) and this branch's Auto encode budget
touch the same planner and protocol paragraph; both rules are kept. The web
player test mocks take the union of both sides' hls.js error details.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The media meter merged each long request into its span list by rebuilding and
re-sorting the list, so a plan that kept a few thousand segment requests spent
about 200 ms in every throughput read. Sort the spans once and add up their
union in a single sweep; the result is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The speed-test rules said Test speed runs whenever no media plays, while the
Settings section hides it on metered and cellular links. Point the first rule
at the second so the two read as one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's v2 schema lint now requires every URL member to declare its format.
bandwidth_probe_url is always an absolute URL built from the request's base,
so it declares format uri. The value sent is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The approvals #2929 carried match no change against the new base, so the
contract diff reports them as stale. The next pull request that changes the
document removes them, as the diff tool expects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
buffering-quality.ts grew past the 800-line limit the size ratchet holds new
TypeScript files to. The plan, event, replan and summary types move to
buffering-quality-types.ts, and the controller re-exports them, so importers
are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit fdbb887 into main Oct 23, 2026
20 checks passed
@Quick104
Quick104 deleted the feat/buffering-quality branch October 23, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code impact: playback Can't play, stalls, or wrong media javascript Pull requests that update javascript code priority: P1 Core-path bug; painful workaround — next after P0 size/XXXL 3000+ added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant