Fix the CI-only AVFoundation crash in audio extraction - #6
Closed
maxthegray wants to merge 2 commits into
Closed
Conversation
This reverts commit f66bc00.
AVAssetExportSession's AppleM4A preset is what CI dies on: swift test has taken SIGSEGV in testExtractAudioWritesM4AWithoutChangingSource on every macos-15 run since audio extraction landed, under both the old exportAsynchronously path and the newer export(to:as:) one, and with both the WAV and the QuickTime fixture. The preset always re-encodes, and on a headless runner that cannot supply its media services it faults rather than returning an error. Replace it with an AVAssetReader/AVAssetWriter copy. Audio that is already AAC is passed straight through into the .m4a container, so extraction is lossless, faster, and instantiates no codec at all; other formats are decoded to PCM and re-encoded. This also drops the deprecated status/error/exportAsynchronously surface and, with it, the back-deployed export(to:as:) shim that force-unwraps error and calls fatalError on any non-terminal status. Feed the test a committed 4.8 KB AAC movie instead of building one at run time, so it no longer depends on the host having a working encoder, and assert the extracted duration so a truncated copy cannot pass.
Owner
Author
|
Superseded — the fix is on beta instead. |
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.
Diagnosis
swift testhas taken SIGSEGV intestExtractAudioWritesM4AWithoutChangingSourceon everymacos-15run since audio extraction landed. Key evidence:eb906aefailed with the same signal 11 in the same test — one commit before 272936c. Both the oldexportAsynchronouslypath and the newerexport(to:as:)path crash identically, so 272936c is not the cause and stays.What is left is
AVAssetExportSessionwithAVAssetExportPresetAppleM4A. The preset always re-encodes, and the runner is a headless Apple Silicon VM that logs a failed media IOService match. It faults instead of returning an error.Fix
Replace the export session with an
AVAssetReader/AVAssetWritercopy. Audio that is already AAC is passed straight through into the.m4acontainer — lossless, faster, and no codec is instantiated at all. Other formats are decoded to PCM and re-encoded.This also removes the back-deployed
export(to:as:)shim, which on macOS 15–25 ran inside Perch's own binary and doesthrow self.error!plusfatalErroron any non-terminal status. With a macOS 14 deployment target that could trap the process for a large share of users on a failed export.The test now uses a committed 4.8 KB AAC movie instead of building one at run time, and asserts the extracted duration so a truncated copy cannot pass.
Verification
swift test: 270 tests, 0 failuresswift build -c release: clean