bevyengine/bevy · error · DrawError

Failed to execute render command {0:?}

Error message

Failed to execute render command {0:?}

What it means

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).

Source

Thrown at crates/bevy_render/src/render_phase/draw.rs:46

    #[expect(
        unused_variables,
        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."
    )]
    fn prepare(&mut self, world: &'_ World) {}

    /// Draws a [`PhaseItem`] by issuing zero or more `draw` calls via the [`TrackedRenderPass`].
    fn draw<'w>(
        &mut self,
        world: &'w World,
        pass: &mut TrackedRenderPass<'w>,
        view: Entity,
        item: &P,
    ) -> Result<(), DrawError>;
}

#[derive(Error, Debug, PartialEq, Eq)]
pub enum DrawError {
    #[error("Failed to execute render command {0:?}")]
    RenderCommandFailure(&'static str),
    #[error("Failed to get execute view query")]
    InvalidViewQuery,
    #[error("View entity not found")]
    ViewEntityNotFound,
}

/// Stores all [`Draw`] functions for the [`PhaseItem`] type.
///
/// For retrieval, the [`Draw`] functions are mapped to their respective [`TypeId`]s.
pub struct DrawFunctionsInternal<P: PhaseItem> {
    pub draw_functions: Vec<Box<dyn Draw<P>>>,
    pub indices: TypeIdHashMap<DrawFunctionId>,
}

impl<P: PhaseItem> DrawFunctionsInternal<P> {
    /// Prepares all draw function. This is called once and only once before the phase begins.
    pub fn prepare(&mut self, world: &World) {

View on GitHub (pinned to 396ca72708)

Solutions

  1. Log the {0:?} payload - it names the exact failing command/reason - then check earlier log lines for the underlying wgpu or asset error.
  2. 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.
  3. In custom RenderCommands, check preconditions and return RenderCommandResult::Skip instead of Failure when the item can be skipped for one frame.
  4. Catch DrawError at the render-node level and skip the frame instead of unwinding the render graph.

Example fix

// before: custom command fails hard when data is missing
fn render(item: &P, view: QueryItem<ViewQuery>, entity: Option<QueryItem<ItemQuery>>, mut param: Param, pass: &mut TrackedRenderPass) -> RenderCommandResult {
    let bind_group = param.bind_groups.get(&item.entity()).unwrap();
    RenderCommandResult::Success
}

// after: skip gracefully, or return Failure only for real errors
fn render(item: &P, view: QueryItem<ViewQuery>, entity: Option<QueryItem<ItemQuery>>, mut param: Param, pass: &mut TrackedRenderPass) -> RenderCommandResult {
    let Some(bind_group) = param.bind_groups.get(&item.entity()) else {
        return RenderCommandResult::Skip; // not ready this frame
    };
    RenderCommandResult::Success
}
Defensive patterns

Strategy: try-catch

Try / catch

match render_phase.render(&mut render_pass, &render_world, view_entity) {
    Ok(()) => {}
    Err(DrawError::RenderCommandFailure(command)) => {
        error!("render command failed: {command}"); // skip frame, keep app alive
    }
    Err(other) => error!("draw error: {other:?}"),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/1a573bc7aed81230. Report an issue: GitHub.