This repository was archived by the owner on May 27, 2025. It is now read-only.
Add RemoveComponents example to demo 'infinite' system bug - #23
Open
mgi388 wants to merge 1 commit into
Open
Conversation
mgi388
force-pushed
the
remove-components-infinite-bug
branch
from
June 22, 2024 02:56
8e0b101 to
cf2f212
Compare
mgi388
pushed a commit
to mgi388/bevy-kira-components
that referenced
this pull request
Nov 7, 2024
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
When you use
AudioFileEndBehavior::RemoveComponents, the system that actually handles the removal of the components loops infinitely. To repro, run the example and look in the terminal at the 'infinite' log entry.The removal code removes
AudioFileBundlebut the query that the system uses queries forAudioHandle<AudioFileHandle>, and that's not a part ofAudioFileBundletherefore the query always matches.I think the logic error is that the removal code assumes that removing
AudioFileBundleis enough, because that's the minimal set of components callers need to add to an entity to make it play audio audio. However, bevy-kira-components can internally add more components. In this case it addsAudioHandle:bevy-kira-components/src/sources/mod.rs
Line 170 in d9bd5ab
Therefore I think one solution is that the removal code just needs to be aware of all of the extra components it may add and one fix looks like this:
This seems to be in line with the original goal of
RemoveComponentswhich is to make the entity look how it looked before the caller addedAudioFileBundlei.e. the caller is really asking bevy-kira-components "please: remove all the audio components".P.S. It was easier to just push the repro example as a PR than create a new issue and I also thought that if it was desired we could keep this example, and once the bug is fixed we can enable the
on_audio_file_removedto demonstrate how you can change sounds once the previous sound has finished playing.