XAudio2: a voice at a reused address drops the stale decoder's state #456
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!456
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-456"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@DavidM1911 on GitHub · 2026-11-24 00:31 UTC · original
DavidM1911:xaudio2-voice-aba→main· +65 −10 · 1 files · 2 commits · openFixes #328.
An
IXAudio2engine released withoutDestroyVoiceon its voices leaves their entries inXMA/DECODED_VOICES(andDECODED_LIVE_COUNTincremented, theDecodedCallbackleaked). When Windows hands the same address to a laterCreateSourceVoice, the new voice inherited them: a plain PCM voice'sSubmitSourceBuffercalls were fed to the stale Opus/XMA decoder.evict_voice()now forgets both tables on every successful create, on the decoded path (create_decoded_voice) and the plain/silent path, before the new entry is inserted.destroy_voiceshares the same take/release helpers, so teardown is unchanged.What is in it
crates/xcl/src/hle/xaudio2.rs:take_decoded_voice/release_decoded_handle/evict_voicehelpers;evict_voicecalled after*ppon both create paths;destroy_voicerefactored onto the helpers; one unit test that plants staleXMA+DECODED_VOICESentries at a fake voice address and checks both maps and the live count after eviction.Tested
x86_64-pc-windows-msvc, debug build:cargo test -p xcl --lib xaudio2: 10 passed, 0 failed (includes the new test; the real-engine XAudio2 tests also pass)cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignoredno wave64recompiler GPU tests (ran on the iGPU in the #42 report)scripts/smoke.ps1 -Seconds 60,cargo build --release -p xcl:main
a6f5f7a:this PR's head
00f0fd5(rerun after a first cold-cache pass showed 685 frames; warm-cache numbers below):Not tested
AI use
@mastrr9 on GitHub · 2026-11-24 01:02 UTC · original
Code audit + NVIDIA RTX 5080 test run on
00f0fd5e08420abac8e000988ea7f919634d466f(fixes #328):Review
Looks clean —
evict_voiceis called on bothcreate_decoded_voiceandcreate_source_voicebefore inserting new entries, and sharingtake_decoded_voice/release_decoded_handlewithdestroy_voicekeeps the teardown logic in one place.evict_voice_drops_stale_entries_at_a_reused_address, assertingDECODED_LIVE_COUNT == 0could flake if another test inxaudio2::testsever holds a live decoded voice concurrently under--test-threads=4; comparing against a pre-test snapshot or delta would avoid that.)Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.hle::xaudio2::tests::evict_voice_drops_stale_entries_at_a_reused_address: passed.SKIPPEDGPU tests (2, wave32-only adapter):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
@DavidM1911 on GitHub · 2026-11-24 01:06 UTC · original
Re-ran the regression smoke on the new head
017515c(test-only change per review — dropped the globalDECODED_LIVE_COUNTassert that raced parallel Opus/XMA2 tests; the per-address assertions stay). RTX 3060 Ti, GTA VI 1.0.2.1, 60 s:cargo test -p xcl --lib xaudio2: 10 passed, 0 failed.@alpz1000 on GitHub · 2026-11-24 01:40 UTC · original
Independent parallel XAudio2 test check at PR head
017515ca0b8f92354c4d06db550e93dcc1aa0288, including the follow-up that removes the global live-count assertion.Tested on Windows 11 Home 26200.9974, Intel Core i5-8400, Rust 1.100.0 x86_64-pc-windows-msvc, debug.
cargo test --locked -p xcl --lib xaudio2 -- --test-threads=4 --nocapturepassed all 10 tests, including the reused-address eviction regression and the tests using system XAudio2. Then I ran that same lib test executable withxaudio2 --test-threads=4in 20 fresh processes. All 20 runs passed all 10 tests with no skips.Not tested: the prior revision's failure rate, full workspace, retail gameplay, or an actual engine-teardown/address-reuse sequence. The stale-address regression uses synthetic state.
AI use: OpenAI Codex (GPT-6) ran the local tests and drafted the report.
@ryosen0 on GitHub · 2026-11-24 01:57 UTC · original
Serial-test confirmation on NVIDIA: head
017515cmerged ontomain508a0c7(clean), with #468 and #508 also applied. RTX 3060 Ti 8 GB, Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11.cargo test -p xcl --lib -- --test-threads=1 title_textures xaudio2 acphal: 27 passed, 0 failed - the stale-decoder eviction test passes with the global live-count assert removed (the removal is right: the count is process-global, parallel tests legitimately move it).--test-threads=1the xaudio2 set is stable here; the race the removed assert caught was test-only, as the review said.Not tested: a retail voice-reuse scenario end-to-end (no audible check).
AI use: GPT-6.2 Astra (API model selector) in DSH ran the tests and wrote this comment; the human contributor reviewed it.
@woreksami on GitHub · 2026-11-24 02:16 UTC · original
Test report: on this machine this PR is what made the title's sound continuous (the choppy sound from #260).
Tested
XCL_NETWORK=0,XCL_PSO_WAIT_MS=150,XCL_DXC_THREADSunsetmain508a0c7+ #214, #267, #300, #503, #468: narration and loading-screen music cut out after 1–2 s, in every run.main9ce2070+ #214 (960162e), #267 (043d1f7), #300 (9507d05), #503 (78f5510), #468 (0d407cf), #572 (14d638a) + this PR (017515c): three runs, the sound was continuous through the menus and the loading screen ("pretty much all of it", by ear). This PR is the only audio change between the two trees.xapustill logs a single1 Opus packets decodedline per run in both trees, so the continuous sound does not come through that path here.cargo test --release -p xcl --libon the merged tree: 658 passed, 0 failed, 21 ignored.Not tested
main(the before/after trees also differ by #451 and #572); AMD; a meter on the audio output (heard by ear only); the workspace suite andscripts/smoke.ps1.AI use
@shdann on GitHub · 2026-11-24 00:47 UTC · original · reviewed
crates/xcl/src/hle/xaudio2.rs:1843asserts that the process has zero decoded voices after the test removes its own voice. The Opus and XMA2 lifetime tests in the same binary can each hold a decoded voice at that point. With parallel tests, eviction can succeed and the count can still be one. The preceding two assertions already check removal of this voice by address. Please keep those assertions and check the global count in an isolated test process if counter coverage is needed. Static review of00f0fd5with OpenAI Codex (GPT-6).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.