Skip to content

fix(display): the master-refusal latch does not outlive the output format it describes - #589

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/refusal-latch-foreground
Sep 22, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/refusal-latch-foreground

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

The master-refusal latch now has an expiry event.

panelRefusedHDRMaster answers a question about an output CONFIGURATION, not about a panel. The user changes that configuration in Settings, the platform reports nothing when they do, and an Apple TV holds one app process for days, so a latch taken in a mode that genuinely refused kept routing every HDR title media-direct long after the mode was changed back.

Reaching the output format means leaving the app, so a real return from the background is the one event guaranteed to follow the change, and setupLifecycleObservers already watches it. The flag is read before it is cleared, so an activation that never backgrounded (a system alert, a volume HUD) is not mistaken for a trip to Settings.

Why this was worth more than the route

The latch's own comment weighed it against "the master route until the app restarts". classicjazz's measurements on #459 show the bill is larger and every item is visible to the viewer:

  • Stats for Nerds reads "Dolby Vision -> SDR" or "HDR10 -> SDR" for every title in the process, which is what Stats report wrong current display mode: HDR10+ -> SDR (when display is HDR locked) #459 was opened about.
  • A Profile 7 source builds its supplemental descriptor and then has nowhere to put it, because a media playlist has no variant to carry it.
  • No master means no EXT-X-MEDIA:TYPE=SUBTITLES rendition, so bitmap subtitles disappear from PiP while the overlay keeps publishing cues to a window nobody can see.

On the reporter's hardware the headroom leg is dead (currentEDR=1.00 potentialEDR=1.00, and the explicit probe reports no HDR reading in 12158ms), so losing the master route there is not losing one of two paths to the answer, it is losing the answer.

What a wrong clear costs

One in-place media fallback, measured at 223 ms with no visible black frame, paid at the next HDR load after a foregrounding rather than once per process. The latch keeps its whole job inside a viewing session, which is where the per-title repetition it exists to prevent would actually have happened.

What this deliberately does not do

Key the latch to a fingerprint of the display configuration. That would be more precise, but the latch can only be set while eligibleForHDRPlayback is true, so the capability table at refusal time may be identical to the table afterwards, and a fingerprint built on that assumption would hold the stale latch silently. That needs measuring on the device before anything is built on it. The background return needs no such assumption.

Tests

Issue588RefusalLatchLifetimeTests, four cases: the latch does not survive a return, the reporter's route recovers without a restart, clearing an unset latch is a no-op, and the observer acts only on a real background return (a source-level check, because a policy test cannot see a notification).

Full suite green, both runners, exit 0: 3306 swift-testing cases in 443 suites, 642 XCTest cases. xcodebuild -scheme AetherEngine -destination 'generic/platform=tvOS' builds, which is the platform the changed observer actually compiles on.

Device verification is still open: the shape that needs a television is refusing a master, changing the output format back, leaving the app and returning, and seeing the master served without a force-quit.

Re #588, reported on #459.

🤖 Generated with Claude Code

https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f

…rmat it describes

`panelRefusedHDRMaster` recorded that AVFoundation refused an HDR master and kept
that answer for the life of the process. The answer is about an output
CONFIGURATION, not about a panel, and the user changes the configuration in
Settings, which the platform never reports. A latch taken in a mode that
genuinely refused therefore routed every HDR title media-direct long after the
mode was changed back, on a box that can hold one app process for days.

Measured by classicjazz on #459: two Apple TVs with identical panel readouts,
one serving the master and one not, three of the four terms in
`sessionRoutesAsHDRPanel` equal across the runs, and a force-quit curing the
second box on the same file and the same television.

The cost was booked as "the master route until the app restarts". It is larger
than that and all of it is user-visible: the label reads SDR for every title, a
Profile 7 source builds its supplemental descriptor and then has no variant to
carry it, and no master means no TYPE=SUBTITLES rendition, so bitmap subtitles
vanish from PiP while the overlay keeps publishing cues to a window nobody sees.

Reaching the output format means leaving the app, so a real return from the
background is the one event guaranteed to follow the change, and the engine
already observes it. Read before the flag is cleared, so an activation that
never backgrounded (a system alert, a volume HUD) does not spend the fallback
for nothing. A panel that still refuses re-earns the latch at the next HDR load
for one in-place media fallback, 223 ms with no visible black frame.

Not keyed to a fingerprint of the display configuration, which would be more
precise: the latch can only be set while `eligibleForHDRPlayback` is true, so the
capability table at refusal time may be identical to the table afterwards, and a
fingerprint built on that assumption would hold the stale latch silently.

Re #588, reported on #459.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant