Skip to content

Drain released audio buffers on notification in the suspend/resume test - #1008

Closed
thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/audio-release-event-test
Closed

thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/audio-release-event-test

Conversation

@thehobbit85

@thehobbit85 thehobbit85 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What and why

The suspend/resume AudioOut test failed under ThreadSanitizer after reclaiming all six PCM buffers in order and within its pacing bounds. It counted five release notifications and expected six. The affected PR changes contributor documentation and inherits the test unchanged from main. Failed job on #691

Current head e0bfe51d62016f804951a5c550f6c5dfd2cdba35. python3 -m unittest dm.tools.tests.test_docs passed on this revision (11 tests). The feature sources, tests and documentation match the previously validated revision d8a6cefd641f byte for byte.

This PR includes main 6136418bcd564f086cf57cb0a59e8f997d36445e. Main’s standalone audio test still counts one notification per buffer. This PR drains all released buffers on a wake while preserving release order and the requirement for real notification.

Local validation on d8a6cefd641f. python3 -m unittest dm.tools.tests.test_docs — 11 tests passed.

The native audio suspend/resume fixture and the repository’s full threaded TSan target passed. A separate probe initially used raw TSan flags and reported two races across uninstrumented CoreAudio calls. The passing target uses the repository’s pre-existing no-inline and runtime settings.

The notification-draining regression is commit e0bfe51d6201. Shared AudioOut test

GitHub checks for this revision

One audio callback can finish several buffers, and the notifier can combine pending wakes. The old test polled the released queue independently of the event, then compared the number of signals with the number of buffers. The silent-sink and suspend/resume scenarios now read the queue only after observing a notification, drain it, and check every buffer’s identity and order. Both keep the original deadline. The suspend/resume case also checks that both transitions ran and the 520 ms playback lower bound held.

Original repair validation

  • Forced the notifier to process its first wake after two buffer releases had posted. Under the repository’s TSan settings, the original test failed with six ordered buffers and five signals. The revised test passed with the same six buffers and five signals.
  • Withheld the sixth notification in a private negative control. The revised test timed out with five of six buffers and failed as intended.
  • On an Apple M2 Max, macOS 26.6 and Xcode 27.0, both make -C dm/host/tests GAME=010015100B514000 tsan-threads and make -C dm/host/tests GAME=010015100B514000 asan passed on the submitted sources. LLVM 23.1.4 checked all 217 sources and matched the existing 271-finding C lint baseline.
  • This changes test executables only. The signal and release-queue implementation stays in the host. No game or device run was needed to reproduce the failure.

@thehobbit85
thehobbit85 force-pushed the codex/audio-release-event-test branch 2 times, most recently from d8a6cef to e0bfe51 Compare November 3, 2026 03:12
@github-actions github-actions Bot added the host The Horizon host: SVCs, services, threads, memory (dm/host) label Nov 3, 2026
seedds added a commit that referenced this pull request Nov 3, 2026
… finish several buffers and the notifier can combine wakes, so the suspend / resume case no longer fails under TSan with 5 of 6 notifications (#1008)

Co-authored-by: thehobbit85 <[email protected]>
@seedds

seedds commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Landed on main as 82246bd, with you credited as co-author. t_audio passed three runs in a row, and the host suite passes. Thanks!

@seedds seedds closed this Nov 3, 2026
@thehobbit85
thehobbit85 deleted the codex/audio-release-event-test branch November 4, 2026 01:27
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
… finish several buffers and the notifier can combine wakes, so the suspend / resume case no longer fails under TSan with 5 of 6 notifications (seedds#1008)

Co-authored-by: thehobbit85 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

host The Horizon host: SVCs, services, threads, memory (dm/host)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants