Missing graph blocks other animation events non-deterministically
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The bug is in trigger_untargeted_animation_events in crates/bevy_animation/src/lib.rs, where a return inside the per-player loop exits early when a graph is missing. Run the reproduction in the issue to see the healthy player's ping count change when a broken player is added. Switching that return to continue should fix it, and the regression test should check that one missing graph does not suppress other players' root events.
Written by the indexing model from the issue text.
Description
Bevy version and features
0.20.1
[Optional] Relevant system information
osx, m1, msrv ...
Overview
crates/bevy_animation/src/lib.rs
in trigger_untargeted_animation_events, a missing graph causes an early return, causing animation events in other graphs to get skipped and lost.
let Some(graph) = graphs.get(graph_id) else {
return; // exits the whole loop
};
...```
This leads to circumstances where depending on the iteration order, for entities with graphs A, B, and C, if B is missing, C can get skipped... or for the order C, A, B, none get skipped. Hard to detect.
Other functions in this file use `par_iter().for_each(|...|)` and return, which does NOT skip the following runs like a sequential loop does.
Either switch iterators, or use `continue` instead of return.
Potentially regression test this.
## Reproduction
Short reproduction example
```rust
//! One player whose graph isn't loaded stops *every* player's untargeted
//! (root) animation events, because `trigger_untargeted_animation_events`
//! uses `return` instead of `continue` when a graph is missing.
use std::time::Duration;
use bevy::{animation::AnimationEvent, prelude::*, time::TimeUpdateStrategy};
#[derive(AnimationEvent, Clone)]
struct Ping;
#[derive(Resource, Default)]
struct Pings(u32);
fn run(spawn_broken_player: bool) -> u32 {
let mut app = App::new();
app.add_plugins((MinimalPlugins, AssetPlugin::default(), AnimationPlugin))
.insert_resource(TimeUpdateStrategy::ManualDuration(Duration::from_millis(50)))
.init_resource::<Pings>()
.add_observer(|_: On<Ping>, mut pings: ResMut<Pings>| pings.0 += 1);
// A clip with one root event at 0.1s.
let mut clip = AnimationClip::default();
clip.set_duration(1.0);
clip.add_event(0.1, Ping);
let clip = app.world_mut().resource_mut::<Assets<AnimationClip>>().add(clip);
let (graph, node) = AnimationGraph::from_clip(clip);
let graph = app.world_mut().resource_mut::<Assets<AnimationGraph>>().add(graph);
if spawn_broken_player {
// A graph handle that points at nothing, like a graph still loading.
app.world_mut()
.spawn((AnimationPlayer::default(), AnimationGraphHandle(Handle::default())));
}
// A perfectly healthy player.
let mut player = AnimationPlayer::default();
player.play(node);
app.world_mut().spawn((player, AnimationGraphHandle(graph)));
// ~0.5s of playback: crosses the 0.1s event once.
for _ in 0..10 {
app.update();
}
app.world().resource::<Pings>().0
}
fn main() {
let alone = run(false);
let with_broken = run(true);
println!("healthy player alone: {alone} ping(s)");
println!("healthy player + one broken player: {with_broken} ping(s)");
if alone == with_broken {
println!("OK: no bug.");
} else {
println!("BUG: the broken player suppressed the healthy player's events.");
std::process::exit(1);
}
}
AI Assisted
I used claude to find bugs in the animation library and write up a reproduction for this one.
- Dominant language
- Rust
- Stars
- 49.8k
- Forks
- 5.1k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 136
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bevyengine/bevy
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26642 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26641 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26635 ·
Maintainers usually reply within 2 days
-
Feathers checkbox outline should have flex_shrink: 0Possibly taken @Tatsuya0330 claimed this today. OpenC-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bevyengine/bevy#26630 ·
Maintainers usually reply within 2 days
-
A-UI C-Examples C-Refinement D-Straightforward S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bevyengine/bevy#26584 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
bug triaged tui ux wontfix
Difficulty 2/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day