Fix busy-wait that stalled video writing under CI load - #11
Merged
Conversation
acj
force-pushed
the
claude/failed-ci-diagnosis-jfvxzo
branch
2 times, most recently
from
June 15, 2026 00:45
3fc6308 to
99ff8fc
Compare
acj
marked this pull request as draft
June 15, 2026 00:51
acj
force-pushed
the
claude/failed-ci-diagnosis-jfvxzo
branch
from
June 15, 2026 10:40
99ff8fc to
77847fd
Compare
The requestMediaDataWhenReady block had two problems that could leave the build hanging until the test timeout: 1. It wrapped the append loop in an outer while-loop over the remaining assets, so when the input's buffer filled (isReadyForMoreMediaData became false) it busy-spun on the media queue, starving the encoder. 2. Finalization (markAsFinished/finishWriting) happened only inside the 'is ready' loop. If appending the final frame filled the input's buffer, the loop exited before finalizing and the writer waited on a readiness callback that never needed to come — an intermittent stall that timed out the multi-frame test. Follow AVFoundation's documented pattern: append while the input is ready, return when it is not so the block is re-invoked, and finalize once the queue is empty regardless of readiness (markAsFinished does not require a ready input). State that must survive re-invocation lives outside the block.
acj
force-pushed
the
claude/failed-ci-diagnosis-jfvxzo
branch
from
June 15, 2026 10:46
77847fd to
b38b176
Compare
The first AVAssetWriter/H.264 use on the CI simulator pays a large, variable cold-start cost (30s+ observed), which landed inside the first video test's timed expectation and could trip its timeout. Pay that cost once in setUp, outside any XCTest expectation, so each test only measures steady-state latency.
acj
force-pushed
the
claude/failed-ci-diagnosis-jfvxzo
branch
from
June 15, 2026 10:50
b38b176 to
066c6e1
Compare
acj
marked this pull request as ready for review
June 15, 2026 11:07
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.
This fixes a race condition that stalled CI and could have caused on-device delays, too. When the writer input's buffer filled (
isReadyForMoreMediaDatareturns), the block kept spinning on the media queue instead of returning, which then starved the encoder threads. The updated code better conforms to the pattern that Apple recommends.