Repository navigation
fix(macos-helper): set audio probe frameLength before PCM copy - #3821
Conversation
AVAudioPCMBuffer starts with frameLength 0, so mDataByteSize stays 0 and CMSampleBufferCopyPCMDataIntoAudioBufferList returns -12731. Set frameLength first, then copy. Add a regression that feeds a real float PCM sample buffer through add(sampleBuffer:) and asserts a non-silent peak. Fixes callstack#3771
|
This change is not ready to merge yet. At b8e3176 the fix looks right, but nothing shows it works on a real audio capture. The change affects the ScreenCaptureKit audio path in AudioProbe.swift. The PR body says no Swift tests and no live audio probe ran. Without a live run, a silent drop back to -90 dBFS would pass every CI lane. Please run Not blocking, and you can take or leave it: AudioProbeTests.swift builds a mono buffer, but ScreenCaptureKit sends two-channel non-interleaved float32, and the checks are loose enough that a copy filling one channel would still pass. Would a stereo case with a different level per channel and an exact peak check (for example -6 dBFS) make the test stronger? CI shows one check pending and none failing, but I could not confirm it is the macos-helper gate, so a green result may not mean the new test ran. There are no conflicts. Once the macOS test and live run are posted, mark the draft ready. |
|
Validated unchanged commit
Portable sound reproduction command (the recorded run invoked the built executable directly): "$(swift build --package-path apple/macos-helper --show-bin-path)/agent-device-macos-helper" audio-probe --duration-ms 3000 --out /tmp/sound.json
cat /tmp/sound.jsonOutput: {"rmsDbfs":[-90,-44,-90,-35,-64],"source":"system-audio","durationMs":3000,"active":false,"peakDbfs":[-90,-24,-78,-20,-57],"stoppedAt":"2026-10-20T15:12:24Z","startedAt":"2026-10-20T15:12:21Z","bucketMs":1000,"elapsedMs":3000,"reason":"completed","sourceCount":1,"state":"stopped","backend":"macos-screencapturekit","heard":true,"sampleCount":5,"audio":"probe"}Portable silence reproduction command (the recorded run invoked the built executable directly): "$(swift build --package-path apple/macos-helper --show-bin-path)/agent-device-macos-helper" audio-probe --duration-ms 3000 --out /tmp/silent.json
cat /tmp/silent.jsonOutput: {"audio":"probe","state":"stopped","heard":false,"reason":"completed","backend":"macos-screencapturekit","source":"system-audio","bucketMs":1000,"sampleCount":5,"rmsDbfs":[-90,-90,-90,-90,-90],"elapsedMs":3000,"durationMs":3000,"stoppedAt":"2026-10-20T15:13:10Z","sourceCount":1,"active":false,"startedAt":"2026-10-20T15:13:07Z","peakDbfs":[-90,-90,-90,-90,-90]}Last 20 lines of the completed unit test run: The worktree remained clean. GitHub CI remains |
|
Thanks, this covers what I asked for at b8e3176. The macOS run shows GitHub CI has not run on this head yet because the fork workflows wait for approval, so a maintainer needs to approve them. There are no conflicts. I am marking this ready for human review. Not blocking: the stereo test case with an exact per-channel peak check is still a possible follow-up. |
* origin/main: (28 commits) feat(gesture): add gesture tap with 2 to 5 simultaneous contacts (callstack#3847) chore: mark 0.21.29 as released chore(diagnostics): trace Apple prepare phases and subprocess lifecycle (callstack#3846) feat(sdk): start an embedded runtime from the main entry (callstack#3843) fix(alert): align local Apple and Limrun button choices (callstack#3825) docs(adr): drop the withdrawn host allocator design from ADR 0021 (callstack#3845) feat(screenshot): support selector crops on CoreDevice iPhones (callstack#3839) feat(scroll): support explicit budgets for long target searches (callstack#3837) fix(apple): key the toolchain fingerprint memo on the resolved xcode-select dir (callstack#3726) feat(android): hand rotation back to the sensor with orientation auto (callstack#3822) fix(sdk): scope released entries and deferred provider calls (callstack#3833) test(android): prepare the snapshot helper before landmark waits (callstack#3834) perf(ci): overlap iOS simulator boot with the native build (callstack#3836) docs(ios): record SpringBoard sessions as verified on a physical iPhone (callstack#3840) feat(apple): admit two-finger gestures on physical iOS devices (callstack#3838) perf(android): bound target readiness and confirm moved clears (callstack#3815) perf(android): reuse live helper for input and capture (callstack#3811) chore(gates): forbid process globals outside declared entry points (callstack#3753) (callstack#3823) refactor(commands): resolve command inputs and output from the caller host (callstack#3753) (callstack#3829) refactor(runtime): use the owning host environment at process boundaries (callstack#3753) (callstack#3828) ...
Summary
audio-probereported -90 dBFS becauseAudioProbeStatusWriter.add(sampleBuffer:)copied PCM whileAVAudioPCMBuffer.frameLengthwas still 0, leaving destination byte sizes at 0 and returning -12731.Set
frameLengthbefore copying. Make the internal writer accessible to its regression through@testable. Two files; no public API change. Fixes #3771.Validation
256aa126598e8cc67a0ba5daf8388b3c60ead711. Unchanged head:b8e317697a8d6b5cb27a4b41dcc7c28a4d72c383.swift test --package-path apple/macos-helperpassed 23 XCTest tests, including the PCM regression;swift build --package-path apple/macos-helperpassed.heard:true, maximum peak -20 dBFS and RMS -35 dBFS. The silence control producedheard:falsewith every bucket at -90 dBFS. The linked record documents the temporary CLT/VFS toolchain workaround used for the live helper.pnpm check:affected --run --headreceipt is still unavailable. Linux, Apple, and Android CI runs remainaction_required, with zero jobs executed. The neutral cubic review is not a test pass.Maintainer CI approval and review remain pending. The additional stereo/exact-peak test suggestion was explicitly optional and is outside this update.