Bevy: Spawing many Entities and then despawing them leads to NoSuchEntity.

Created on 27 Aug 2020  路  13Comments  路  Source: bevyengine/bevy

I was trying to create a minimal project for another problem an I came upon this.
The minimal example project is the example ui/text with those lines:

`struct Item {
max_time: f32,
time: f32,
}

fn add_items(mut commands: Commands) {
for _ in 0..1000 {
commands.spawn((Item {max_time: 1.0, time: 0.0}, ));
}

}

fn update_items(mut commands: Commands, time: Res

After a while I get:

thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: NoSuchEntity', C:\Users\kakoeimon\.cargo\git\checkouts\bevy-f7ffde730c324c74\89a1d36\crates\bevy_ecs\src\system\commands.rs:75:36 note: run withRUST_BACKTRACE=1environment variable to display a backtrace error: process didn't exit successfully:target\debug\no_such_entity.exe(exit code: 101)

The minimal example project

no_such_entity.zip

bug ecs

Most helpful comment

Ah oops cargo update, yeah this makes sense. Glad it's working for you now ^-^

All 13 comments

I confirmed I see the same thing on mac with the current master commit of https://github.com/bevyengine/bevy/commit/3efbaca10452427385822f79208ff3a78ab9edda

Here is an even more stripped down example (I just deleted more things from the example provided above).

no_such_entity.zip

Most likely related to #117.

The example project I provided still panics.
I know it is not a real life test but...

Are you using the git version of bevy or the crates.io version?
If you're using the crates.io version this fix wont be there until a new a release

The git, have you tried the example project?

Yeah it was what I used to check that the PR fixed the issue it says it does x)
Could you try running cargo clean and then rebuilding and see if that fixes it?

Be sure to cargo update the example project too. The sample project's Cargo.lock is behind in changes. Without doing so, I recreate the panic, but after updating, it goes away for me.

Everything look OK!
cargo clean and cargo update did the trick!
Sorry for my ignorance, I will keep that in mind.
Thanks.

Ah oops cargo update, yeah this makes sense. Glad it's working for you now ^-^

Just to inform you, I got the bug again in my project.
Looks like it was a bad luck, but I thought it will be good to inform you.

You'll get the same error message if you despawn the same entity twice (And from some other functions, a stacktrace would be useful if wishing to determine the actual cause :) ). Could be that

I just found the problem and it was mine.
As you said I despawned the entity twice.
Sorry for bothering you.

Not a problem! I'm glad you followed up, even if it ended up being on your side. It could have been an issue with bevy, and we want to fix issues with bevy :smile:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TehPers picture TehPers  路  4Comments

Nickan picture Nickan  路  4Comments

rod-salazar picture rod-salazar  路  4Comments

navaati picture navaati  路  5Comments

jamadazi picture jamadazi  路  4Comments