Skip to content

Software path starts SDR playback without waiting for the frame-rate switch it just requested #885

Closed

Description

@akhanwav

What happened?

For SDR sources the software path writes rate-only display criteria and then plays at once, while the panel may still be renegotiating HDMI for the new refresh rate.

From the 7.47.0 source:

  • DisplayCriteriaController.apply returns .applied for SDR (Display/DisplayCriteriaController.swift:859-860, "SDR rate-only switches are sub-second; only HDR criteria need the waitForSwitch delay"). So the pre-load wait at AetherEngine.swift:4955-4968 runs only for .willSwitch, which is HDR only.
  • The native branch then gates play() on the panel (AetherEngine.swift:5620, waitForSwitch(startGrace: Self.playGateGrace(…)), .brief for an engine-written SDR switch).
  • The software branch (loadSoftware at 5519, softwareHost?.play() at 5556) has no equivalent gate, so an SDR rate switch is never waited for there.

On our box a rate-only switch is not always negligible. On the native path, a switch from 23.977 to 50 Hz was observed starting 558 ms before gate entry and settled 370 ms after it, so it ran about 0.9 s in all. Our host's own transcode route, waiting on the mode-switch notifications, measured 2.5 to 2.7 s from criteria write to settle, though those switches also changed dynamic range. Most panels blank or blink during the handshake, so on the software path the first second or so of an AV1, VP9, MPEG-2 or VC-1 SDR title plays into it.

We found this by reading the source, not on a device: we had no software-path SDR title to hand. A play gate on the software branch matching the native one (the .brief grace for an engine write) looks like the fix.

Steps to reproduce

  1. Match Content on (Match Frame Rate on), home screen at 60 Hz.
  2. Load an SDR source that takes the software path (AV1, VP9, MPEG-2 or VC-1) at a rate other than the panel's, for example 23.976 fps.
  3. Expect [DisplayCriteria] SET: format=sdr … rate=23.976 followed directly by playback, with no switch settled or play-gate line in between.

AetherEngine version or commit SHA

7.47.0 (source reading); also present in 7.32.3 and 7.42.0

Host app

Custom / my own integration (Rivulet)

Platform

tvOS

OS version

tvOS 26.6 (23L773)

Device / chip

Apple TV 4K (3rd generation), AppleTV14,1

Playback path

Software (dav1d) host

Activity

  1. superuser404notfound commented on Oct 26, 2026

    @superuser404notfound
    Owner

    Thanks for the careful read, the analysis is right for 7.47.0 and earlier.

    This landed in 7.48.0 (released today) with 73098d9, which came in alongside the software-host AirPlay work from @pkajaba. The software branch now runs the same play gate as the native one before softwareHost?.play():

    • same playGateGrace(...) inputs, so an engine-written SDR rate switch gets the .brief grace,
    • same settleCap (.awaitObservedEnd for VOD, .standard for live, so a zap does not sit behind a handshake),
    • noWriterExpected additionally covers awaitsInboundCriteriaWrite, because there is no AVPlayerItem on this path for AVKit to derive criteria from.

    The rate-only case you describe is covered by the observation that apply() arms right before the criteria write (#339), not by the start-phase budget: a switch that started while the software pipeline was being built is seen as already running at gate entry, and the gate then waits for its end, which is the 558 ms before / 370 ms after shape you measured on the native path. A switch that already ended before the gate exits immediately.

    Release notes line: "The software host waits for a running display-mode switch before it starts playing (tvOS)."

    On a device the sequence should now read [DisplayCriteria] SET: format=sdr ... rate=23.976, then either switch settled before the gate opened or a settle line from the gate, then playback. I'll leave this open for a device check on an SDR software-path title (AV1 without HW decode, VP9, MPEG-2 or VC-1) against 7.48.0.

  2. akhanwav commented on Oct 27, 2026

    @akhanwav
    Author

    Thanks for the quick fix and the detailed explanation! I can’t test 7.48.0 on device just yet: as in #883, releases from 7.43.0 on don’t build on my Xcode 26.3, and I’m moving to Xcode 27 soon. I’ll run the SDR software-path check (AV1/VP9/MPEG-2/VC-1) as soon as I’m on it and report the log sequence here.

  3. superuser404notfound commented on Oct 27, 2026

    @superuser404notfound
    Owner

    Good news for the check: 7.49.0 builds on Xcode 26.3 again (#883), and it still carries the software-path play gate from 7.48.0, so the SDR software-path run can go against 7.49.0 without waiting for Xcode 27.

  4. akhanwav commented on Oct 28, 2026

    @akhanwav
    Author

    Thanks for the fix in 7.48.0. On 7.49.0 an SDR VC-1 1080p 23.976 MKV takes the software path and plays normally (dispatch: codec=70 → software). I tested with Match Content off, though, so the engine logged no wait: Match Content disabled and there was no rate switch for the play gate to wait on. I couldn't confirm the gate itself yet and will report the SET → settled → play sequence once I've run it with Match Frame Rate on.

  5. superuser404notfound commented on Oct 29, 2026

    @superuser404notfound
    Owner

    Thanks, that already confirms the dispatch side on 7.49.0: VC-1 goes to the software host and plays. And no wait: Match Content disabled is the correct gate outcome for that setting, nothing can start a switch there, so the gate skips its budget instead of sitting on it.

    The same VC-1 1080p 23.976 file is a good candidate for the real check. With Match Frame Rate on (and the panel not already at 23.976), the expected sequence is:

    1. [DisplayCriteria] SET: format=sdr ... rate=23.976
    2. either switch settled before the gate opened (the switch finished while the pipeline was still being built) or a settle line from the gate itself with the measured switch time
    3. playback starts after that line, not before it

    If the panel is already at 23.976 from a previous title, no switch happens and the gate exits early, so switching to a 50/60 Hz title or the home screen first gives the useful run. Leaving this open for that report.

  6. akhanwav commented on Oct 30, 2026

    @akhanwav
    Author

    Confirmed on device with Match Content (Frame Rate) on: same Apple TV, an SDR VC-1 1080p 23.976 MKV on the software path, started from the home screen.

    11:48:22.152 [DisplayCriteria] SET: format=sdr codec=hvc1 rate=23.976 extensions=none
    11:48:22.152 [AetherEngine] dispatch: codec=70 → software
    11:48:22.803 [DisplayCriteria] rate-only criteria already satisfied (start pre-gate (start notification, before gate entry) 206ms before gate entry, total 193ms, panel 23.976Hz, the requested rate; released 5807ms before the 6000ms cap)
    11:48:23.352 [AudioOutput] preroll ready after 159 ms; starting at t=90.890 rate=1.0
    11:48:26.622 [DisplayCriteria] mode check (software): content=23.976 requested=23.976 panel=23.976Hz (nominal 23.976) player=n/afps
    

    The gate saw the switch start and released once the panel reported 23.976 Hz. Playback started 550 ms after that, and the following 35 s showed lost=0 skip=0 layerDrop=0. Thanks!

    One difference from the lines you expected: the gate logged ‘rate-only criteria already satisfied’ rather than ‘switch settled before the gate opened’ or a settle line. Before this title the box sat on the home screen for about 10 s after a 24 Hz title, so I can’t fully confirm the panel’s rate before the switch, and the switch (~400 ms) looked fast. Happy to rerun from a 50/60 Hz title if that path isn’t what you’d expect.

  7. superuser404notfound commented on Oct 31, 2026

    @superuser404notfound
    Owner

    Thanks, that run confirms the fix, no rerun needed.

    rate-only criteria already satisfied is the third exit of the same gate, the one I left out of the list above. Reading the line:

    • start pre-gate ... 206ms before gate entry: the mode-switch start notification arrived while the software pipeline was still being built, so the panel did switch for this title. If it had already been at 23.976 Hz, no start would have been recorded and the gate would have logged no switch started instead.
    • The switch was still running at gate entry (otherwise the line would be switch settled before the gate opened), so the gate went into its wait for the end.
    • It released 193 ms later because the panel already measured the requested 23.976 Hz, before tvOS delivered the end notification (that is why there is no switch ... ms end to end figure). This is the A rate-only criteria write for a rate the panel already runs spends the full 2 s cap holding play() #449 release for engine-written rate-only switches, whose end notification often arrives late or never.

    So start to release took about 400 ms, playback began 550 ms after the release on a panel at the right rate, and lost=0 skip=0 layerDrop=0 afterwards is exactly the outcome the gate is for. Closing this as fixed in 7.48.0, thanks again for reading the source closely enough to spot it and for the device check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions