Repository navigation
fix(display): size the play-gate start grace by what can still switch (#274) - #277
Merged
Merged
Conversation
…#274) The post-load play-gate calls waitForSwitch() before nativeHost.play() so the first decoded frame does not hit a mid-transition panel. Its Stage 1 blind-polls up to 1000 ms for a switch to START, a budget raised from 200 ms in 5d60dbb for exactly one case: a sole-writer host (suppressDisplayCriteria) whose criteria write lands during the load, from AVKit's auto path reading dvcC off the live AVPlayerItem. DV P5 cold start needs it. Every other session paid the same 1000 ms for a write that could not arrive, which is dead startup time, not safety: - Engine-writer sessions wrote their criteria synchronously before loadNative. Any switch that write triggers started long before the gate runs, and .willSwitch already settled it in the pre-flight, so a second full blind poll buys nothing. - SDR content reaches no dynamic-range switch at all. The only write anyone can still make is rate-only, and the engine already declines to gate its own rate-only writes (apply() returns .applied with no pre-flight wait) because those switches are sub-second. waitForSwitch takes a StartGrace (skip / brief 200 ms / full 1000 ms); AetherEngine.playGateGrace is the pure decision, covering the #133 unchanged-criteria skip as well. A failed probe keeps the full budget on a suppressed host, because the source range is then unknown and a DV write may still be inbound. The audio-switch reload gate goes through the same rule: it preserves the criteria and re-applies none, so only a host re-write on the swapped item can switch anything. Second defect from the same report: the Stage 2 settle classification read didApply == false as the HDR branch, so a sole-writer host's own SDR rate write settling with EDR headroom 1.0 logged "WARN switch ended but EDR headroom still 1.0 (panel stayed SDR despite HDR criteria)". The engine has no target range to compare against for a write it never made. switchEndOutcome makes that a third, neutral case. Both decisions are pure and unit-tested (DisplayCriteriaPlayGateTests). Reported and measured by @digilearn-dev (#274). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes nothing yet: reporter retest pending.
What the report found
With
LoadOptions.suppressDisplayCriteria = truethe engine skips its ownapply()(only.clearStaleruns), but the post-load play-gate still calledwaitForSwitch()with the same budget as every other session. @digilearn-dev measured a residual startup cost on VOD loads where nothing was in flight for the engine to wait on, plus a mis-attributedWARN ... panel stayed SDR despite HDR criteriafor a switch their own host had initiated.Root cause
Two independent defects, both from the gate not knowing who writes criteria.
1. Stage 1 budget.
waitForSwitchStage 1 blind-polls for a switch to start. It went 200 ms -> 1000 ms in 5d60dbb for one architecture: an AVKit-sole-writer host whose criteria write fires from the liveAVPlayerItem.formatDescriptionduring the load. DV P5 has no HDR10 base layer, so its first frame must not hit an SDR panel, and that budget is what made the cold start land. Every other session paid it for a write that could not arrive:loadNative. Whatever switch that triggered started long before the gate runs, and a.willSwitchwas already settled by the pre-flightwaitForSwitch. A second full blind poll buys nothing.apply()returns.appliedwith no pre-flight wait) because those settle sub-second.2. Settle attribution. Stage 2's classification was
didApply && !lastCriteriaWasHDR -> rate-only, else -> WARN HDR failure. On a sole-writer hostdidApplyis false, so a host SDR rate write that correctly ended SDR fell into the HDR-failure branch. The engine cannot attribute a switch it did not initiate.The fix
waitForSwitch(startGrace:)takes.skip/.brief(200 ms) /.full(1000 ms).AetherEngine.playGateGraceis the pure decision:A switch that genuinely started still settles in Stage 2 unchanged, and the entry fast-exit on EDR headroom is untouched, so an already-HDR panel still returns instantly. The audio-switch reload gate routes through the same rule: it preserves the criteria (
resetDisplayCriteria: false) and re-applies none, so only a host re-write on the swapped item can switch anything there.switchEndOutcome(didApply:lastCriteriaWasHDR:)adds the third case and logs it neutrally instead of warning.What deliberately did not change
The report proposed skipping
waitForSwitchentirely whensuppressDisplayCriteria == true. That is the one case the gate was built for (5d60dbb, validated on DrHurt's Build 173 DV P8.4 testing), so skipping there would trade this startup cost for a DV P5 cold-start regression on AVKit-auto hosts. The budget is now sized by whether a dynamic-range switch can reach the session, which covers the reporter's SDR loads without touching that guarantee.Verification
swift test: 1396 tests in 210 suites pass, including the newDisplayCriteriaPlayGateTests(both decisions are pure).xcodebuild -scheme AetherEngine -destination 'generic/platform=tvOS Simulator' build: clean.applyTiming/isHDRCriteria, and the newno switch started ... after 200msline names the budget that was used.🤖 Generated with Claude Code
https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE