Repository navigation
fix(swplayback): name a software session that decodes into nothing (#298) - #300
Merged
Merged
Conversation
) A packed-bitstream XviD AVI reported as "the renderer stops accepting frames": audio played to completion, no picture, and `[Renderer] enqueue #30 ... ready=false` read as the stall. That line is what a healthy session prints. `isReadyForMoreMediaData` is the demux loop's back-pressure gate, so a full queue right after an enqueue is the gate working, and the counter reaching #100 at t+4.7s on a 23.976 fps source is real-time pacing. A queue that had genuinely stopped draining would have parked the one demux loop that also feeds audio within a queue depth, and the audio would have stopped with it. The same three lines, with the same pts=0.042s first frame, reproduce on an `-c:v mpeg4 -bf 2` AVI through `aetherctl play --sw`, which binds no view at all and therefore shows nothing either. That is the gap this closes. A software session renders into `SampleBufferRenderer.displayLayer`, which reaches the screen only once the host binds a surface; a host presenting AVPlayerViewController gets audio, a clean log and no picture, because this path has no AVPlayerItem for AVKit to show. The same holds for a layer bound to a view that never got a layout. Both are now named once per session, ~2 s after frames start flowing, with the frame count that went nowhere. Second, the renderer refuses a frame whose PTS is not numeric. AV_NOPTS_VALUE arrives as `CMTime.invalid`, CoreMedia builds a sample buffer from it without complaint (measured: noErr, PTS reads back as NaN seconds), and the render synchronizer cannot pace it; the deinterlace path already drops its untimestamped output for that reason. The gate sits before the reorder buffer, where a NaN also breaks ordering for its neighbours (every comparison against NaN is false). Nothing on this source needs it: the demuxer runs +genpts, so AVI's missing anchor-frame timestamps are regenerated (NOPTS_pts=0 on the fixture). It closes the mechanism the report hypothesised and counts what it drops, so a source that does produce untimed frames says so. 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.
What #298 reported
A packed-bitstream XviD AVI: audio plays to completion, the picture never appears, and the session log reads
which was read as "the renderer stopped accepting frames".
What the measurement says
isReadyForMoreMediaDatais the demux loop's back-pressure gate (SoftwarePlaybackHostparks on it before feeding a video packet), so a full queue immediately after an enqueue is the gate working. The counter reaching #100 at t+4.74s on a 23.976 fps source is real-time pacing, and a queue that had genuinely stopped draining would have parked the one loop that also feeds audio within a queue depth, taking the audio with it.Reproduced locally on
ffmpeg -f lavfi -i testsrc -c:v mpeg4 -vtag XVID -bf 2 ... .avithroughaetherctl play --sw: the same three lines, the samepts=0.042sfirst frame,VERDICT: OK, clock advancing. aetherctl binds no view at all, so it also shows nothing.That is the actual gap. A software session renders into
SampleBufferRenderer.displayLayer, which reaches the screen only once the host binds a surface (AetherEngine.bind(view:)/AetherPlayerSurface). A host presentingAVPlayerViewControllerinstead gets audio, a completely healthy engine log, and no picture, because this path has noAVPlayerItemfor AVKit to show (the reporter's log hasplayerItem.status=0, loading=YESand_becomeNowPlaying denied: no player itemthroughout). Nothing named that condition.Changes
1. Surface visibility,
SoftwarePlaybackHost. Once per session, 8 ticks (~2 s) after frames start flowing, on the main actor:and the sibling case, a layer bound to a view that never got a layout:
The delay covers a host that binds during load plus the first layout pass.
assessSurface(hasSuperlayer:size:)is a pure function so both verdicts are pinned without a live layer.2. Unschedulable frames,
SampleBufferRenderer.AV_NOPTS_VALUEreaches the decoder callback asCMTime.invalidand CoreMedia builds a sample buffer from it without complaint (measured:CMSampleBufferCreateReadyWithImageBufferreturns noErr and the sample's PTS reads back as NaN seconds), so the display queue was the first place it could do damage. The deinterlace path already drops its untimestamped output for that reason; this is the same rule one layer lower, before the reorder buffer, where a NaN also silently breaks ordering for its neighbours (every comparison against NaN is false). Drops are counted and named.This is hardening, not the cause: the demuxer runs
fflags +genpts, so AVI's missing anchor-frame timestamps are regenerated (pktdumpon the fixture:NOPTS_pts=0, presentation orderI(1) B(2) B(3) P(4)). It closes the mechanism the report hypothesised and makes a source that genuinely produces untimed frames say so.Not changed
No stall watchdog /
.errortransition. Nothing is stalled here, and a watchdog on "ready has been false for a while" would fire on healthy back-pressure, which is the exact reading this issue is about. Engine logging already goes throughos_log(subsystemde.superuser404.AetherEngine, categorysw.playback), which is how the reporter captured these lines.Verification
Issue298SoftwareSurfaceTests),swift build -Xswiftc -strict-concurrency=completeclean, tvOS SimulatorBUILD SUCCEEDED.aetherctl play --swon the AVI fixture emits the new line at t≈1.9s, in the same position the reporter's log would have shown it.🤖 Generated with Claude Code
https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE