Repository navigation
fix(native): keep playback log reads off the main thread - #566
Conversation
aac321e
into
superuser404notfound:main
|
Merged as aac321e. Thank you, this is a careful piece of work, and it closes the half of #134 that was left open: the notification reads, the .failed dump and the counter retirement were still synchronous getters on the main actor, so a busy media server could still park the UI there. On the CI timeout: the base run you linked was genuinely red, but it was infrastructure rather than the base commit. 3d72e67 is 0027df2 plus one README line and its Two things worth noting for the record, neither of them blocking. The retired byte and dropped frame totals now reset on prepareForItemHandover, so an episode handover starts a fresh session total instead of carrying the previous episode's bytes into it. That reads as the correct behaviour for AE#443 and the new test pins it, it is just a change the description does not call out. And AVFoundationOffMain's own doc comment still says the queue is a caller-owned serial one, while the pool hands it a concurrent queue on purpose; that comment gets a follow-up here. |
#566) The comment promised a serial queue, which stopped being true when ItemDiagnosticReadPool started passing a concurrent one to keep a second lane open for the incoming item. Name both shapes and why the choice belongs to the caller. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
The two lanes shared a private concurrent queue. A concurrent queue draws from the non-overcommit root, so it stops starting work as soon as the global pool is saturated, which is the state a stranded media server produces. The carrier failed in the one case it existed for. Measured on macOS 27, 8 cores, with 64 work items blocked on the global pool: a private concurrent queue and DispatchQueue.global() had not started after 30 s, a private serial queue started in 0.2 ms, a Thread in 0.1 ms. Pushing to ~512 blocked overcommit threads stops the serial queue too, so a queue moves the wall and a thread removes it. The lanes already count their own admission, so each read now carries a thread for exactly its own lifetime, two lanes meaning at most two threads. The three serial-queue callers keep their queue, which there IS the admission policy. The pool test asserts the carrier alongside the lane bound, so a return to a shared queue fails where the bound is checked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
…n threads (#566) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
…573) External contribution by @tschuegy. `SoftwarePlaybackHost.seek(to:)` handed the session-axis target straight to the demuxer, the packet store, the decoder's skip threshold and the synchronizer clock, all of which speak the source's own timestamps. On a mid-stream-joined source (#107) the demuxer clamped to the start of the file and the store's reservoir read as the whole offset, so the producer stopped reading and the picture stood with nothing reported. Verified on merge: `Demuxer.seekBounded(to:)` takes an absolute source timestamp (it passes `seconds * AV_TIME_BASE` into `avformat_seek_file`, and the time-seekable path subtracts `sourcePTSOriginSeconds` itself), so the carry does not double-apply; `SoftwarePacketReadAhead` is fed the raw clock via `updatePlayhead`, so its keyframes and frontier really are source-axis; and `clockSessionZero` is `firstSample - initialSeconds`, which keeps the mapping correct after a resume as well. Resolved the CHANGELOG conflict against #566/#568 and dropped three em-dashes for the house style. CI green on 51b4b78, local `swift build --build-tests` green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
Pin the upstream release containing the merged background diagnostic-read and bounded subtitle OCR fixes from superuser404notfound/AetherEngine#566 and superuser404notfound/AetherEngine#568. Resolve the engine's FFmpegBuild 3.4.0 dependency without changing unrelated pins. Update the playback documentation and exact-release source credit, and assert the compiled engine version in the integration suite. Keep existing playback routing and optional feature settings unchanged.
Summary
A tvOS hang report showed the main thread blocked for about 41 seconds while reading
AVPlayerItem.accessLog(). This moves the remaining playback log reads off the main thread and out of AVFoundation callbacks, following #134.What changed
This prevents diagnostic reads from blocking the UI; it does not fix the underlying media-service stall. The report's exact application caller remains unsymbolicated.
Test plan
On an Apple Silicon Mac running macOS 27 / Xcode 27: 111 targeted tests passed, including blocked-getter, notification-burst, teardown and synchronous item-replacement regressions. The 12 new tests also passed five repeat runs. macOS build and tvOS Simulator library/test-bundle compilation passed; no physical-device reproduction is claimed.
CI: full macOS tests hit the 30-minute limit; the unchanged base had a matching timeout. All other checks passed.
Checklist