Skip to content

Preview: an Auto trailer whose remote preflight gets no response plays the Original - #1430

Merged
GLinnik21 merged 2 commits into
mainfrom
fix/preview-direct-original
Nov 17, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
fix/preview-direct-original

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1425

What

I made the detail page's trailer preview plan as Original (a direct play) when, on Auto with a remote server, Auto's remote Original preflight gets no response at all: its open failed in the network, so nothing was measured. The preflight still runs for a preview, and any sample of the link still decides as before, so a link too slow for the file still refuses the preview, as on main. Full plays, fixed rungs and quality Original are unchanged.

The route says why, beside the existing auto: / route: lines. The existing auto: remote Original preflight produced no capacity sample failure=Open(Transport(28)); using HLS line is still printed first, and its "using HLS" no longer holds for a preview, so the next line says what happened:

route: Auto preview — the remote Original preflight got no response, so it measured nothing; planned as Original (a preview is direct play or nothing); source 5000kbps 1920x806

Why

A preview is direct play or nothing (preview: refused — not a direct play, the preview gate in plan.rs). For a Plex extra at /services/iva/assets/…/video.mp4 the preflight's open can fail with Open(Transport(28)) after the two cross-origin redirects in the report. There is then no sample, abr::bootstrap denies with ProbeInconclusive, Auto chooses HLS, and the preview gate refuses it. A refusal that rests on no evidence about the link is the only outcome Auto could give a preview. Which phase of the open hit rc=28 is not known (the report has no timings). The probe's budget for a 5000 kbps source is 1000 ms for setup and 1000 ms for the body (abr/original.rs:21, decision.rs:9472), which is consistent with it, not proven.

I first planned every Auto preview as Original and dropped the preflight. Review showed that goes too far: a trailer can also be a local file the PMS serves from /library/parts/ at any bitrate, and over a slow link a skipped preflight direct-plays it at link capacity with nothing to rescue it (auto_original_watched is false for a preview, and a Load that fails before the first picture arms the preview breaker in player/preview.rs). So the preflight stays, and only its empty answer is read differently.

The change:

  • decision.rs: measure_remote_original returns a typed RemoteProbe (decision.rs:9505) instead of an Option:
    • Sample(CapacityObservation): the server answered and bytes were read, however few (the sample's own completed says whether the target was reached).
    • NoResponse: the open failed in the network, OpenErr::Transport(_) or OpenErr::Deadline (DNS, TLS, connect, a timeout, or the setup deadline before the first header).
    • Unmeasured: everything else (no source bitrate, a status or range refusal from the server, local machinery failing, a transfer that failed after it had opened).
    • The remux caller takes .sample(), so full plays and the remux probe read exactly what they read before.
  • plan.rs: the Auto arm records whether a direct-play preflight came back NoResponse (plan.rs:2681). A preview with that outcome counts as auto_original (plan.rs:2753), so there is no HLS override and the gate sees a plain direct play. For any other outcome the code is main's again: preview_already_refused, the adaptive override and the PreviewRefusal::Adaptive path are reachable as before, and their comments are main's.
  • plan.rs:2067: the URI qualifier's private copy of the Force Direct Play quality mapping now reads playback_quality, the quality the planner settled on. The value is the same as before (the planner no longer changes the quality for a preview); it just stops being a second copy that could drift. The qualifier runs before the preflight, so it cannot see a NoResponse result; the URI engine declines a preview anyway.

Behaviour changes to know about, all for a Remote Auto preview:

  • Preflight returns no response: was refused as adaptive, now direct plays (the Auto, remote: the detail page's trailer is refused because the Original preflight times out on its CDN redirect #1425 case).
  • Preflight passes: still direct plays, with the same route: Auto Original … line a play gets (unchanged from main).
  • Preflight yields a sample, complete or not: unchanged. A slow measured link still refuses the preview as adaptive.
  • The server answers the Part with a refusal (a 503 after a transcode MDE, a range it ignores): unchanged, still refused. Only a failure of the network open counts as no response.
  • A failure after the open (body deadline, short or broken body): unchanged, still refused.
  • Local and Relay links, fixed rungs and quality Original: unchanged.

Tests

All in rust-modules/media/src/route/plan_audio_enhancement_tests.rs, on the existing loopback-PMS resolve rig (which records every request line). I added a PartAnswer::Hangup to decision_test_support.rs: the Part GET is closed with no response, which curl reports as a transport failure of the open (Open(Transport(52))), the shape of the report's Transport(28).

  1. a_preview_on_auto_whose_preflight_gets_no_response_direct_plays_the_original asserts a Part URL, no verdict, no HLS contract, no watch, the preflight GET still on the wire, the no capacity sample failure=Open(Transport( line, one route: Auto preview line and no route: Auto adaptive. It also checks the plan has the same contract and Part path as a preview under Original, which makes no Part GET.
  2. a_preview_on_auto_whose_preflight_measures_a_slow_link_is_still_refused: an Ok sample with target_reached false (a 100 KB body for a 6 MB target) is refused as adaptive, the same verdict as on main, with route: Auto adaptive and no route: Auto preview.
  3. a_preview_on_auto_whose_part_the_server_refuses_is_still_refused: a 503 on the Part GET is refused as adaptive.
  4. the_same_item_played_in_full_on_auto_still_starts_hls_when_the_preflight_gets_no_response (control): the same failing open with preview off makes the Part GET and starts a FixedHls plan.
  5. a_preview_under_original_is_unchanged: direct play, no Part GET, progressive contract, no ceiling, no route: Auto line.

a_direct_playable_preview_that_auto_sends_to_hls_is_refused_as_adaptive and a_transcoded_preview_under_auto_is_not_direct_even_though_auto_also_chose_hls are main's, untouched.

Red on origin/main. With main's plan.rs and decision.rs and only the test files added (PartAnswer::Hangup and the new tests), make test-crate C=plx_media T=plan_audio_enhancement_tests:

test route::decision::plan_audio_enhancement_tests::a_preview_on_auto_whose_preflight_gets_no_response_direct_plays_the_original ... FAILED
not refused: Some(PreviewNeedsDirectPlay { reason: Adaptive })
test result: FAILED. 48 passed; 1 failed; 0 ignored; 0 measured; 2207 filtered out; finished in 0.62s

Only test 1 is red. Tests 2 to 5 pass on main and with the fix, because they pin what must not change. With the fix: test result: ok. 49 passed; 0 failed; 0 ignored; 0 measured; 2207 filtered out; finished in 0.64s.

Gates, on the committed tree (git status --short empty before and after each):

make test-crate C=plx_media     test result: ok. 2152 passed; 0 failed; 104 ignored; 0 measured; 0 filtered out; finished in 32.57s
make test-hostsim C=plx_media   test result: ok. 2432 passed; 0 failed; 104 ignored; 0 measured; 0 filtered out; finished in 58.34s
make check-nodef                Finished `dev` profile [unoptimized + debuginfo] target(s) in 15.25s
bash ci/check-deps.sh           check-deps: all gates green
python3 ci/check-module-layers.py   check-module-layers: green — 18 layers, 1952 modules, 169 Cargo layer declarations, 0 migration entries left in ci/allow/layers.txt, 0 of them into [port webos]; 0 cfg(test) items still named across layers (--report)

Not verified

  • No television. I did not play a trailer on the set, so the reporter's redirect chain and a real CDN were not exercised. That a direct open then plays rests on the report (quality Original plays the same URL). The rig's Hangup is a stand-in for the report's Transport(28), not the same errno.
  • A preview whose open failed before any header over a link that is in fact slow direct-plays with nothing to rescue it. That is the cost of reading "no response" as "no evidence"; the preview breaker is the existing backstop. I did not measure it.
  • One pr-reviewer pass ran on the first version; its MAJOR (a local trailer over a slow link) is why this version is narrow. Not run: the full make check and the ARM cross-build (CI runs both), and doc-claim-auditor. No release-note line added.

Not changed: a full play of the same trailer on Auto remote

A full play (Play Trailer, Action::PlayTrailer → request_play with preview: false) goes through the same (Quality::Auto, Some(Remote)) arm and the same preflight. If the 1 s probe gets no response, the trailer starts as Auto-adaptive HLS at the 480p-class fallback rung (720 kbps in the report). It is not refused, only degraded. This is from reading the code, not a run. This PR leaves it as it is; it is the owner's call.

  • Is the probe's URL the right one to sample? For a library file the Part is served by the PMS, so the sample measures the TV-to-PMS link, which is what Original would use. A trailer stored in the library is served the same way. An extra the PMS redirects to an external CDN is different: Original's bytes then come from the CDN, so the sample measures the path Original would use, but with one second for DNS, TLS and headers across two cross-origin hops, a budget sized for one PMS hop.
  • Does its result mean anything as an HLS prior for the PMS link? For the redirecting kind, no. HLS segments come from the PMS, which fetches the trailer itself, so a CDN rate (or a CDN timeout) says nothing about the TV-to-PMS link, yet bootstrap turns a completed sample into the starting rung and a weak prior for the live estimator, and an incomplete one into the 480p fallback.
  • What a fix would be. Either give the planner a typed fact for an extra whose direct URL leaves the PMS origin (an extra's context is already known, ResolveEnv::omit_queue_continuous derives from ExtraContext::of(ctx), but the redirect itself is only known once the open is made) and plan it as Original without the PMS preflight, relying on the existing Original-to-HLS rescue (a full play is auto_original_watched) if the CDN stalls; or, narrower, apply this PR's rule to full plays: only a NoResponse preflight plays the Original, and a measured slow sample still goes to HLS. A full play has the rescue, so that would be safer there than it is for a preview. The cost of either is that a slow CDN is found by a stall instead of by a one-second probe. Leaving it alone is also defensible: Auto's "HLS when unsure" is deliberate and the play still starts.
  • Not determined: which phase hit rc=28.

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits November 17, 2026 17:49
The detail page's preview only ever plays a direct play. With quality Auto
and a remote server, build_stream still ran Auto's remote Original
preflight for it, which can only turn a playable trailer into a refusal:
a Plex extra redirects twice to an external CDN, the preflight's setup
budget (about a second for a 5000 kbps source) ran out on those hops, no
capacity sample came back, Auto chose HLS and the preview gate refused it
("preview: refused - not a direct play (adaptive)").

A preview whose quality is Auto now plans as Original, the way a forced
direct play already does, through the planner's own ResolveEnv.preview
fact: no preflight GET, no Auto decision, one event-log line saying why.
A fixed rung is untouched, as is every non-preview play on Auto. The
now-unreachable preview_already_refused guard goes, and the comments that
named Auto's HLS as a preview refusal are corrected.

Closes #1425

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The first fix planned every Auto preview as Original, skipping the remote
preflight. A local trailer the PMS serves at any bitrate over a slow link
then direct-played at link capacity with nothing to rescue it (a preview's
Original is never watched, and a Load that fails before a picture arms the
preview breaker), where main refused it on the preflight's slow sample.

Keep the preflight and the Auto decision for a preview. Type the
preflight's outcome (RemoteProbe: Sample, NoResponse, Unmeasured) and plan
the preview as Original only on NoResponse: an open that failed in the
network (Transport or the setup deadline), so nothing was measured. Any
sample, even an incomplete one, still decides as on main, and so does a
server's own refusal of the Part. Full plays are unchanged. The preview
guard, the Adaptive refusal path and their comments are main's again, and
the URI qualifier reads the quality the planner settled on.

Closes #1425

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21 GLinnik21 added bug Something isn't working playback Playback, the player and its controls labels Nov 17, 2026
@GLinnik21
GLinnik21 merged commit f149b88 into main Nov 17, 2026
17 of 19 checks passed
@GLinnik21
GLinnik21 deleted the fix/preview-direct-original branch November 17, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working playback Playback, the player and its controls

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto, remote: the detail page's trailer is refused because the Original preflight times out on its CDN redirect

1 participant