{"record":{"id":"1a573bc7aed81230","repo":"bevyengine/bevy","slug":"failed-to-execute-render-command-0","errorCode":null,"errorMessage":"Failed to execute render command {0:?}","messagePattern":"Failed to execute render command (.+?)","errorType":"exception","errorClass":"DrawError","httpStatus":null,"severity":"error","filePath":"crates/bevy_render/src/render_phase/draw.rs","lineNumber":46,"sourceCode":"    #[expect(\n        unused_variables,\n        reason = \"The parameters here are intentionally unused by the default implementation; however, putting underscores here will result in the underscores being copied by rust-analyzer's tab completion.\"\n    )]\n    fn prepare(&mut self, world: &'_ World) {}\n\n    /// Draws a [`PhaseItem`] by issuing zero or more `draw` calls via the [`TrackedRenderPass`].\n    fn draw<'w>(\n        &mut self,\n        world: &'w World,\n        pass: &mut TrackedRenderPass<'w>,\n        view: Entity,\n        item: &P,\n    ) -> Result<(), DrawError>;\n}\n\n#[derive(Error, Debug, PartialEq, Eq)]\npub enum DrawError {\n    #[error(\"Failed to execute render command {0:?}\")]\n    RenderCommandFailure(&'static str),\n    #[error(\"Failed to get execute view query\")]\n    InvalidViewQuery,\n    #[error(\"View entity not found\")]\n    ViewEntityNotFound,\n}\n\n/// Stores all [`Draw`] functions for the [`PhaseItem`] type.\n///\n/// For retrieval, the [`Draw`] functions are mapped to their respective [`TypeId`]s.\npub struct DrawFunctionsInternal<P: PhaseItem> {\n    pub draw_functions: Vec<Box<dyn Draw<P>>>,\n    pub indices: TypeIdHashMap<DrawFunctionId>,\n}\n\nimpl<P: PhaseItem> DrawFunctionsInternal<P> {\n    /// Prepares all draw function. This is called once and only once before the phase begins.\n    pub fn prepare(&mut self, world: &World) {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_render/src/render_phase/draw.rs#L28-L64","documentation":"DrawError::RenderCommandFailure(&'static str) is produced in RenderCommandState::draw (draw.rs:344) when a RenderCommand's render() returns RenderCommandResult::Failure(reason). The string payload identifies what failed inside the command. It propagates out of RenderPhase::render / render_range and means a GPU-side precondition failed while drawing a phase item (missing bind group, missing pipeline, missing buffer, unsupported operation).","triggerScenarios":"A queued RenderCommand (built-in like SetItemPipeline/SetMeshBindGroup or a custom one) returns RenderCommandResult::Failure from render(); e.g. the pipeline cache has no pipeline for the item's specialization key, a mesh/bind group is missing from its resource, or a custom command hits an unmet precondition.","commonSituations":"Custom materials/pipelines where a component the draw path expects was never extracted to the render world; meshes or textures still mid-upload when the phase drew; shader specialization mismatch; wgpu validation errors inside a command; render features queueing items whose assets were freed the same frame.","solutions":["Log the {0:?} payload - it names the exact failing command/reason - then check earlier log lines for the underlying wgpu or asset error.","Verify everything the command needs is extracted and prepared before the phase runs: extract the component, register/init the pipeline, let the asset finish preparing.","In custom RenderCommands, check preconditions and return RenderCommandResult::Skip instead of Failure when the item can be skipped for one frame.","Catch DrawError at the render-node level and skip the frame instead of unwinding the render graph."],"exampleFix":"// before: custom command fails hard when data is missing\nfn render(item: &P, view: QueryItem<ViewQuery>, entity: Option<QueryItem<ItemQuery>>, mut param: Param, pass: &mut TrackedRenderPass) -> RenderCommandResult {\n    let bind_group = param.bind_groups.get(&item.entity()).unwrap();\n    RenderCommandResult::Success\n}\n\n// after: skip gracefully, or return Failure only for real errors\nfn render(item: &P, view: QueryItem<ViewQuery>, entity: Option<QueryItem<ItemQuery>>, mut param: Param, pass: &mut TrackedRenderPass) -> RenderCommandResult {\n    let Some(bind_group) = param.bind_groups.get(&item.entity()) else {\n        return RenderCommandResult::Skip; // not ready this frame\n    };\n    RenderCommandResult::Success\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match render_phase.render(&mut render_pass, &render_world, view_entity) {\n    Ok(()) => {}\n    Err(DrawError::RenderCommandFailure(command)) => {\n        error!(\"render command failed: {command}\"); // skip frame, keep app alive\n    }\n    Err(other) => error!(\"draw error: {other:?}\"),\n}","preventionTips":["In custom RenderCommands, verify resources (bind groups, pipelines, buffers) exist and return Skip instead of Failure when the item can wait a frame.","Ensure components your draw path reads are extracted to the render world before the phase runs.","Log the failure payload immediately - it names the failing command and pairs with an earlier wgpu error explaining the root cause."],"tags":["bevy","render-command","draw","gpu","render-phase"],"backgroundTag":"render-command-failed","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}