Repository navigation
Description
Split out of Sodalite#49 so it does not live only in a merged PR body. PR #338 fixed the measurement defects that were hiding this; this is the thing they were hiding.
The shape
waitForSwitch registers its AVDisplayManagerModeSwitchStart / ...End observers on gate entry (DisplayCriteriaController.swift, Stage 1 setup). When the engine is the criteria writer, the write happens in the pre-flight, before the item is built, so the switch can start and finish outside that window. Both notifications are then missed and the only remaining evidence is isDisplayModeSwitchInProgress, which the surrounding comment already calls unreliable ("can read false for a beat right after the criteria write").
What the reporter's logs show
Three runs on an Apple TV 4K (3rd gen), tvOS 26.5, 29.97 SDR content, all on the native path:
| writer | outcome |
|---|---|
engine (SET: sdr rate=29.970) |
proceed after cap, 2082 ms, end never reported |
| engine (identical run) | proceed after cap, 2088 ms, end never reported |
AVKit (engine wrote no criteria) |
host switch ended, 3238 ms, end reported |
Only the run where the engine wrote nothing ever saw an end. In that run the item was ready at t+0.50s and the gate correctly held play() until t+3.25s. In the two engine-written runs the ceiling expired and play() proceeded into a switch whose state was unknown.
That is also the split in the original Sodalite#49 report: the reporter's judder was present with the engine writing and absent with appliesPreferredDisplayCriteriaAutomatically=true + suppressDisplayCriteria=true, which is the row that reports an end.
Two things follow
-
Observer lifetime. Arming the recorder at the criteria write, rather than at gate entry, would make start and end observable in the engine-writer case and turn the pre-gate / in-gate question into a comparison of two timestamps instead of a flag reading.
inGateFlagOnlyfrom Classify a late in-progress flag as an in-gate start, and spend budgets as deadlines (Re Sodalite#49) #338 is the signal that tells us how often the notification is actually being missed, so there is now a way to tell whether this change works. -
The
.briefpremise.StartGrace.brief(200 ms) rests on d87b54d's assumption that engine rate-only writes settle sub-second. The one directly measured rate-only switch on this panel took ~2.9 s, and two more never reported settling inside 2 s. One panel is not enough to re-size a budget every session pays, but the assumption can no longer be cited as established.
Not urgent
The reporter no longer sees the judder, so there is no live symptom driving this. It touches apply(), which carries DV P5 cold start, #133 and #176, and it needs hardware to verify. Filing it so the next round of display-criteria work starts from the measurements rather than rediscovering them.
Activity
superuser404notfound commentedon Aug 9, 2026
One more angle from the Sodalite#49 thread, raised by DrHurt (comment): Stage 2 is blind to what kind of switch it is waiting out.
Stage 1 is already attribution-aware through
playGateGrace(200 ms when the engine wrote the criteria or the format is SDR, 1000 ms only when a dynamic-range write can still arrive). Stage 2 is not: once a start is seen, it waits for an end up to the 2000 ms cap regardless of whether a range change is pending. Only the range change can fail hard (DV P5 has no HDR10 base layer, P8.1 races an AVPlayer error mid-write); a rate-only switch that never reports an end costs two seconds of cold start and returns no information.That is the same cell of the table as the observer problem above, from the other side: with the observers armed at the write instead of at gate entry, an engine rate-only switch would end on a real signal rather than on the ceiling, and the question of capping rate-only separately only arises for whatever is still unobservable afterwards. Ordering the work that way keeps it from being a bet against the only measurement on the thread, where the judder appeared in the configuration that proceeds after the cap and not in the one that waits the switch out.
fix(display): observe mode switches from the manager that posts them (#…
fix(display): a recorded start, not a fresh one, rules out the headro…
fix(display): let both gates of a load read the same switch record (#339
docs(display): record what the Stage 2 cap is actually doing (#339, A…
Merge pull request #345 from superuser404notfound/fix/339-arm-switch-…
superuser404notfound commentedon Aug 9, 2026
Closed by #345, but the title of this issue is wrong and worth correcting for anyone who finds it later.
The observers were not registered too late. They were registered on the wrong object. tvOS posts
AVDisplayManagerModeSwitchStart/...Endfrom anAVSharedDisplayManager, while the engine listened on theAVDisplayManagerthatwindow.avDisplayManagerreturns and thatpreferredDisplayCriteriais written to. Device probe listening on all objects (Apple TV 4K 3rd gen, tvOS 26.5):Six start/end pairs arrived in three playbacks while the filtered observers recorded none. Moving the arming point, which is what this issue proposed, changed nothing about that on its own.
It was still worth doing, for a reason that is not the one written above: with the arming in place, the settle line reported
flag only, start notification missedinstead of quietly attributing the switch to the flag, and that turned a suspicion into a one-run answer. The distinction paid for itself immediately.Two things followed from being able to see the switch at all. The panel's own handshake measures 2779 to 2898 ms across twelve runs, dynamic-range and range-plus-rate alike, which is the first hardware number this budget discussion has ever had. And the EDR headroom, which had been standing in as the end signal, peaks during the transition: it released
play()2478 ms before the panel finished. Both are fixed in #345 and documented on the constants.The startup-latency thread that grew out of this is #348.
fix(display): arm the mode-switch observation at the criteria write (s…