Repository navigation
Conversation
ma_resource_manager_data_stream_init_ex() acquired both the init and the done fence, but the LOAD_DATA_STREAM job only ever releases the init fence. A done fence passed to a stream stayed held forever, so ma_fence_wait() on it never returned. A stream has no separate done stage, so only the init fence is acquired now. Adds a resource manager test that checks every fence passed to a stream is released.
mackron
added a commit
that referenced
this pull request
Nov 13, 2026
The issue with this one is that is that when a "done" fence is used with a stream it'll never actually get signaled because there's no notion of a "done" stage. Public issue #1199
Owner
|
Thanks. I fixed this manually with a different approach to your suggestion, and I also didn't want your tests. In the dev and dev-0.12 branches. |
niu2x
pushed a commit
to niu2x/miniaudio
that referenced
this pull request
Nov 13, 2026
The issue with this one is that is that when a "done" fence is used with a stream it'll never actually get signaled because there's no notion of a "done" stage. Public issue mackron#1199 (cherry picked from commit 6ec7f05)
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.
Hi,
I use miniaudio in a game engine called NonVisual Gaming Toolkit (NVGT), in a private fork with my own modifications. This PR to the resource manager was made entirely by AI. Here is the problem:
ma_resource_manager_data_stream_init_ex()callsma_resource_manager_pipeline_notifications_acquire_all_fences(), which acquires both the init and the done fence. TheLOAD_DATA_STREAMjob only receivespInitFenceand only releases that one, and no other stream job references the done fence. So a done fence passed to a stream stays held forever, andma_fence_wait()on it never returns.In our case the engine registers the same fence on
notifications.donefor every sound and waits on it before uninitializing the sound, to make sure the load job is done with it. That worked for decoded and encoded buffers, but closing a streamed sound hung forever.ma_sound_config.pDoneFenceis documented as "Not used with streams", butinitNotifications.done.pFencereaches the stream anyway. Even throughpDoneFence, "not used" reads as "ignored", not as "never released".A stream has no separate done stage, so the fix only acquires the init fence in
ma_resource_manager_data_stream_init_ex(), and the error path after a failedma_resource_manager_post_job()only releases that one. A done fence passed to a stream is now ignored, as the documentation says. An alternative would be to pass the done fence to the load job and release it together with the init fence. I'm happy to change it to that if you prefer.This PR also adds
tests/resource_manager, registered with CTest. It initializes a stream asynchronously with an init fence, a done fence, and both, then polls each fence's counter with a 5 second timeout instead of waiting on it, so a failure doesn't hang the test. It builds with-std=c89 -Wall -Wextra -Wpedanticwithout warnings.Results on Windows 11 (GCC 16.2, MinGW-w64):
dev(631161e4)dev+ this fix#1198 also adds
tests/resource_manager, with a different test. If both are accepted, the second one to be merged will conflict intests/resource_manager/resource_manager.candCMakeLists.txt. I'll rebase it to register both tests.This was found while investigating a hang reported by players of an audio game built on NVGT. The investigation, the fix and the test were done by an AI assistant (Claude).
I release this contribution into the public domain / under MIT No Attribution, as in miniaudio's license.
🤖 Generated with Claude Code