bevyengine/bevy · critical
Bin not present
Error message
Bin not present
What it means
During entity removal (mod.rs:635), a displaced instance (swapped in to fill the hole left by swap_remove) must be re-filed into its bin; 'Bin not present' fires when that bin's slot in the bins vector is None. It is the downstream half of the same removal path as 'Entity not in bin' and 'Bin key not present' and indicates the same class of bookkeeping desync.
Source
Thrown at crates/bevy_render/src/render_phase/mod.rs:634
match instance_removal_result.displaced_instance {
// Case 1: The instance was removed from the middle of the array. In
// that case, we have a *displaced entity* that was swapped in to
// fill the hole. We need to update the table that maps binned mesh
// instance index to entity and the reverse table that maps entity
// to binned mesh instance index.
Some((displaced_instance_index, displaced_instance)) => {
debug_assert_eq!(
displaced_instance_index.0 + 1,
self.binned_mesh_instance_index_to_entity.len() as u32
);
let displaced_entity = self.binned_mesh_instance_index_to_entity.pop().expect(
"If an entity was displaced, the list of mesh instances must be nonempty",
);
self.binned_mesh_instance_index_to_entity
[instance_removal_result.removed_instance_index.0 as usize] = displaced_entity;
self.bins[displaced_instance.bin_index as usize]
.as_mut()
.expect("Bin not present")
.entity_to_binned_mesh_instance_index
.insert(
displaced_entity,
instance_removal_result.removed_instance_index,
);
}
// Case 2: The instance was removed from the end of the array. In
// that case, we have no displaced entity, so all we need to do is
// to remove it from the instance index to entity table.
None => {
debug_assert_eq!(
instance_removal_result.removed_instance_index.0 + 1,
self.binned_mesh_instance_index_to_entity.len() as u32
);
let removed_entity = self.binned_mesh_instance_index_to_entity.pop();
debug_assert_eq!(removed_entity, Some(main_entity));
}View on GitHub (pinned to 221e52ae32)
Solutions
- Upgrade Bevy to the latest patch release.
- Reduce double-removal / same-frame churn that stresses the bin lifecycle.
- Report upstream with a minimal repro; this is an engine invariant guard.
Defensive patterns
Strategy: fallback
Prevention
- Avoid double-removal patterns that stress bin bookkeeping under multidraw batching.
- Test spawn/despawn-heavy scenes when upgrading Bevy versions.
- Report upstream when this fires without custom bin manipulation.
When it happens
Trigger: An entity removal displaced an instance whose recorded bin_index points at a freed or empty slot in the bins vector while the instance tables still reference it.
Common situations: Same contexts as the other bin panics: heavy spawn/despawn churn with multidraw batching, interleaved bin freeing and instance removal, Bevy upgrade regressions.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Entity not in bin
- Bin should be present
- Bin key not present
- Cannot call `ReflectComponent::reflect_mut` on component {na
- Cannot call `ReflectComponent::reflect_unchecked_mut` on com
AI-assisted analysis of bevyengine/bevy@221e52ae32 (2026-08-20).
Data as JSON: /api/errors/3b987e8785d188a7.
Report an issue: GitHub.