Repository navigation
Description
What happened?
On AetherEngine 7.31.1, a seekable, zero-origin H.264/AAC VOD loaded with startPosition: 17.3 initially reports 17.3 seconds, but the software path re-anchors its clock to 9.984 seconds when playback begins. About three seconds later engine.clock.currentTime is only 12.8–12.9 seconds. This reproduces both with autoplay = false followed by play() and with autoplay = true.
Expected: the initial resume retains the requested position, discards/handles necessary decode preroll, and advances from approximately 17.3 seconds. A caller should not need a second transport seek to establish the initial resume anchor.
This is reproduced using only the engine API and generated media. There is no application session logic, network source, audio-track switch or timestamp-origin offset involved.
Engine version and environment
- Unmodified upstream tag 7.31.1, commit
b085eee1bdd426d50be9dd770d49cecb60e08cb8, the latest stable release at retest. - FFmpegBuild 3.6.0, LibDovi 2.1.0.
- macOS 27.0.1 (26A434), Apple M1 / arm64, Xcode 27.0 (27A266a), Apple Swift 6.4.
- Software path forced through the engine's debug testing switch; native controls verify
playbackBackend == .native. - Headless engine-clock measurements, muted volume. These results do not claim physical-device or audible/visual-output validation.
Steps to reproduce
Generate a completely synthetic, 30-second MP4 with ten-second GOPs:
ffmpeg -hide_banner -loglevel error \
-f lavfi -i testsrc2=size=320x180:rate=24 \
-f lavfi -i sine=frequency=440:sample_rate=48000 \
-t 30 -c:v libx264 -preset ultrafast -b:v 180k \
-g 240 -keyint_min 240 -sc_threshold 0 \
-c:a aac -b:a 32k -movflags +faststart -y resume-long-gop.mp4Media: H.264 Constrained Baseline, 320×180, 24 fps, yuv420p, AAC-LC mono 48 kHz. Both streams and the container start at 0.000 seconds; container duration is 30.000 seconds. No HDR/Dolby Vision, disc, live or external subtitles.
Minimal engine API sequence (run in a macOS debug executable linked to the exact upstream tag):
import AetherEngine
import Foundation
@MainActor
func reproduce(url: URL, software: Bool = true,
autoplay: Bool = false, seekBeforePlay: Bool = false) async throws {
AetherEngine.setForceSoftwarePathForTesting(software)
defer { AetherEngine.setForceSoftwarePathForTesting(false) }
let engine = try AetherEngine()
defer { engine.stop() }
engine.volume = 0
var options = LoadOptions()
options.autoplay = autoplay
options.suppressDisplayCriteria = true
_ = try await engine.load(url: url, startPosition: 17.3, options: options)
let deadline = ContinuousClock.now.advanced(by: .seconds(15))
while engine.state == .loading, ContinuousClock.now < deadline {
try await Task.sleep(for: .milliseconds(20))
}
print("load", engine.playbackBackend, engine.state, engine.clock.currentTime)
if seekBeforePlay { await engine.seek(to: 17.3) }
if !autoplay { engine.play() }
for tick in 1...6 {
try await Task.sleep(for: .milliseconds(500))
print(tick, engine.state, engine.clock.currentTime)
}
}Call with the local generated file URL and defaults for the failing paused-load case, or with autoplay: true for the other failing case. Use a fresh engine per run. For the workaround control, use seekBeforePlay: true and keep autoplay false; the measured control also subscribed to seekEvents and observed a matching landed(17.3) before Play. Use software: false for the native controls.
Repeated measurements
Each cell below represents three fresh-engine runs, sampled after six 500 ms sleeps (approximately 3.0–3.2 seconds after Play or the autoplay load).
| Fixture | API sequence / route | Clock at final sample | Result |
|---|---|---|---|
| 10 s GOP | software paused load → Play | 12.811–12.917 s | 3/3 reproduce |
| 10 s GOP | software autoplay load | 12.912–12.921 s | 3/3 reproduce |
| 10 s GOP | software paused load → seek(17.3) → Play | 20.301–20.303 s | 3/3 advance correctly |
| 10 s GOP | native paused load → Play | about 20.300 s | 3/3 advance correctly |
| 10 s GOP | native autoplay load | 20.200–20.400 s | 3/3 advance correctly |
| 2 s GOP | software paused load → Play | 20.178–20.239 s | 3/3 advance correctly |
| 2 s GOP | software autoplay load | 20.234–20.241 s | 3/3 advance correctly |
The two-second GOP twin uses the same generation command with -g 48 -keyint_min 48; all five modes were repeated three times and advanced correctly. Thus the long-GOP failure is repeatable rather than a general failure to start the headless engine.
Relevant log lines
One failing run:
LOAD run=1 mode=sw-paused backend=software state=paused clock=17.3
[SWHost] clock re-anchored to first sample: anchor=9.984s (load anchor 17.300s, sessionZero=0.000s)
RESULT run=1 mode=sw-paused actual=12.810517625 jumpedBack=true advanced=false
The paused-seek control, on the same source and target:
seek#1 programmatic began target=17.30
seek#1 programmatic landed rendered=17.30 target=17.30
RESULT run=1 mode=sw-seek-control actual=20.302830208 jumpedBack=false advanced=true
ffprobe -read_intervals '17.3%+0.2' on the generated ten-second-GOP source confirms the necessary backward demux landing:
codec_type,pts_time,dts_time,flags
audio,9.984000,9.984000,K__
video,10.000000,10.000000,K__
audio,10.005333,10.005333,K__
Likely mechanism / requested engine behavior
The observed re-anchor is direct engine evidence. The following explanation is a source-based inference:
- Initial software load performs the backward demux reposition and sets the video skip threshold plus
initialClockTimeto 17.3. - First decoded audio arming passes the preroll buffer PTS into
SWClockAnchorPolicy.resolve. - The anchor policy treats any absolute deviation greater than two seconds as a re-anchor. Here the first sample is earlier, not a mid-stream join ahead of the load anchor; it chooses 9.984, and
max(0, firstSample - initialSeconds)leavessessionZeroat zero. The published clock therefore moves backward.
Could the initial software VOD resume preserve its requested anchor while consuming/discarding preroll, with the existing intentional mid-stream-join behavior retained? The paused transport seek already establishes the requested clock correctly on the same source, so the extra seek is a workaround rather than the desired load contract.
I searched existing Issues/PRs and comments before reporting. #337 addresses a cold-start unarmed-clock deadlock; #573 addresses a non-zero-origin seek-axis conversion. This fixture starts at zero, has ordinary promptly interleaved audio, and reproduces without either condition. If there is an existing report for this exact initial-resume/preroll case, please link it and this can be consolidated.
Activity
fix(sw): a resume on an offset-origin source lands on its target (#724)
chore(release): prep 7.32.2 - a software resume lands where it was as…
superuser404notfound commentedon Oct 8, 2026
Thanks for the precise report, the fixture and the exact API sequence made this a one-step repro. Released in 7.32.2.
Your reading of the mechanism was right.
SWClockAnchorPolicycompared the absolute deviation, so a first sample behind the anchor (the audio that comes with the keyframe before the target) was treated like a mid-stream join. It now re-anchors only on a sample ahead of the anchor; preroll behind it is discarded as on a transport seek (a20c4fb).Two related defects turned up while measuring, both in the same release:
autoplay = falseand noplay(),currentTimefell from 17.3 to 0.00 within 250 ms: the host's 4 Hz publisher wrote the still unarmed synchronizer over the anchor. Your harness probably sampled before the first tick, which is why it printed 17.3. VOD now publishes nothing until the clock is armed (same commit).-output_ts_offset 600landed on the first packet (600.000) while publishing 17.3, becauseload()handed the session-axis position to the demuxer unconverted. The resume now carries the source origin first; the first picture lands at 617.292, matching the native path (9d246d8).Measured with
aetherctl play --swon your 10 s GOP fixture, 3 runs per arm:play()aetherctl play --start-positionnow also fails a run whose clock settles more than a second behind the anchor, so this case cannot pass the harness again unnoticed (874e9b4).This was verified headless on macOS only. A retest with your harness on 7.32.2 would be very welcome, and I'll leave the issue open until then.
fix(sw): a resume keeps its anchor when the first sample is preroll (s…
test(aetherctl): play judges where a resume lands (superuser404notfou…
alsoeoe commentedon Oct 9, 2026
Thanks for the fix. I retested the unmodified 7.32.2 tag (
59355d973cfe35d34a19d85d33b7b1ae88e11115) using the original harness and byte-identical 10 s / 2 s GOP fixtures. The original five modes were unchanged, with three fresh engines per mode and fixture. Target: 17.3 s; six samples at 500 ms intervals after Play or the autoplay load.I also reran the original 7.31.1 binary against the long-GOP fixture in the same environment as a negative control.
Values are final clock ranges after approximately three seconds; the seek and native controls also passed 3/3 per cell. The two previously failing software modes pass without an additional seek.
Additional checks, also three fresh engines per mode:
-c copy -output_ts_offset 600. ffprobe reports video start 600.000000 s and audio/container start 599.978667 s. Software paused-load/Play and autoplay both logged the first decoded video frame at 617.292 s in all six runs; final session clocks were 20.199–20.211 s and 20.233–20.238 s respectively. Native controls advanced normally, and software paused-only retained 17.300 s. This checks the decoded frame PTS as well as the published clock.54/54 fresh-engine runs on 7.32.2 passed. No sampled playback clock fell behind 17.3 s, and no clock re-anchor was logged. Same macOS 27.0.1 / Apple M1 arm64 / Xcode 27.0 / Swift 6.4 environment; FFmpegBuild 3.6.0 and LibDovi 2.1.0 unchanged.
These are muted, headless macOS engine tests only; no physical-device, audible-output or on-screen rendering validation is claimed. From this retest, I consider the reported engine issue resolved. Thanks for fixing the two related cases as well.
superuser404notfound commentedon Oct 9, 2026
Thank you for the thorough retest, including the 7.31.1 negative control and the decoded-frame PTS check on the offset source. 54/54 on 7.32.2 settles it, closing as resolved in 7.32.2.