{"record":{"id":"e53738003be16545","repo":"bevyengine/bevy","slug":"bin-should-be-present","errorCode":null,"errorMessage":"Bin should be present","messagePattern":"Bin should be present","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_render/src/render_phase/mod.rs","lineNumber":531,"sourceCode":"{\n    /// Creates a new [`RenderMultidrawableBatchSet`] containing an empty set of\n    /// bins.\n    fn new() -> RenderMultidrawableBatchSet<BPI> {\n        RenderMultidrawableBatchSet {\n            gpu_buffers: RenderMultidrawableBatchSetGpuBuffers::new(),\n            bin_key_to_bin_index: HashMap::default(),\n            bins: vec![],\n            bin_free_list: vec![],\n            indirect_parameters_offset_to_bin_index: vec![],\n            binned_mesh_instance_index_to_entity: vec![],\n            instance_count: 0,\n        }\n    }\n\n    /// Returns the first entity in the first bin (if there is one).\n    pub(crate) fn representative_entity(&self) -> Option<MainEntity> {\n        let first_bin_index = self.bin_key_to_bin_index.values().next()?;\n        let first_bin = self.bin(*first_bin_index).expect(\"Bin should be present\");\n        first_bin\n            .entity_to_binned_mesh_instance_index\n            .keys()\n            .next()\n            .copied()\n    }\n\n    /// Returns the [`RenderMultidrawableBin`] for the given [`RenderBinIndex`].\n    pub(crate) fn bin(&self, bin_index: RenderBinIndex) -> Option<&RenderMultidrawableBin> {\n        self.bins\n            .get(bin_index.0 as usize)\n            .and_then(|bin| bin.as_ref())\n    }\n\n    /// Inserts an entity with the given uniform index into the bin with the\n    /// given key.\n    fn insert(\n        &mut self,","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/bevyengine/bevy/blob/221e52ae323febfd399bd7d067918fc43648cfb3/crates/bevy_render/src/render_phase/mod.rs#L513-L549","documentation":"representative_entity() (mod.rs:532) takes the first bin index from bin_key_to_bin_index and expects the corresponding slot in bins to be occupied; 'Bin should be present' fires when that slot is None (on the free list). It indicates the key-to-index map and the bin free-list have desynchronized - an internal invariant break in RenderMultidrawableBins, not a user input error.","triggerScenarios":"The bins free-list marked a slot empty while bin_key_to_bin_index still mapped a key to that index (or a bin was freed without dropping its key mapping); afterwards representative_entity() is called during GPU-driven render graph building.","commonSituations":"Almost always an engine-side bookkeeping bug in the multidraw bin lifecycle; surfaces during heavy spawn/despawn churn with multidraw batching enabled, or after Bevy upgrades.","solutions":["Update Bevy to the newest patch release for that minor line.","As a workaround, avoid the multidrawable path (use the regular binned/instance paths) until fixed.","Report upstream with a minimal reproduction; this expect guards an engine invariant, not user input."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin a Bevy version where the issue does not reproduce until a fix ships.","Reduce spawn/despawn churn during GPU-driven rendering or disable the multidrawable path if unstable on your version.","Report reproducible internal-invariant panics to the Bevy tracker with the backtrace."],"tags":["bevy","multidraw","bin","panic","gpu-driven"],"backgroundTag":"internal-invariant-violation","analyzedSha":"221e52ae323febfd399bd7d067918fc43648cfb3","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}