bevyengine/bevy · error

Pipeline has not been compiled yet. It is still in the 'Queu

Error message

Pipeline has not been compiled yet. It is still in the 'Queued' state.

What it means

CachedPipelineState::unwrap() panics when the pipeline is still in the 'Queued' state: it was registered in the PipelineCache (queue_render_pipeline/queue_compute_pipeline) but the background creation task has not started yet. Bevy compiles pipelines asynchronously over multiple frames, so unwrap() only succeeds once creation finished. On the first frames after queueing, the state is Queued and this panic fires.

Source

Thrown at crates/bevy_render/src/render_resource/pipeline_cache.rs:74

    Err(ShaderCacheError),
}

impl CachedPipelineState {
    /// Convenience method to "unwrap" a pipeline state into its underlying GPU object.
    ///
    /// # Returns
    ///
    /// The method returns the allocated pipeline GPU object.
    ///
    /// # Panics
    ///
    /// This method panics if the pipeline GPU object is not available, either because it is
    /// pending creation or because an error occurred while attempting to create GPU object.
    pub fn unwrap(&self) -> &Pipeline {
        match self {
            CachedPipelineState::Ok(pipeline) => pipeline,
            CachedPipelineState::Queued => {
                panic!("Pipeline has not been compiled yet. It is still in the 'Queued' state.")
            }
            CachedPipelineState::Creating(..) => {
                panic!("Pipeline has not been compiled yet. It is still in the 'Creating' state.")
            }
            CachedPipelineState::Err(err) => panic!("{}", err),
        }
    }
}

// The default webgpu `max_bind_groups` is 4. Most desktop GPUs support 8.
// Since the element size we used below is small, we inline 8 on the stack.
const BIND_GROUP_LAYOUTS_INLINE_CAPACITY: usize = 8;

type ImmediateSize = u32;
type LayoutCacheKey = (
    SmallVec<[BindGroupLayoutId; BIND_GROUP_LAYOUTS_INLINE_CAPACITY]>,
    ImmediateSize,
);

View on GitHub (pinned to 8d743eb7dc)

Solutions

  1. Match on the state instead of unwrap(): only build bind groups and draw when the state is CachedPipelineState::Ok(_)
  2. Split systems so pipelines are queued in one system and consumed in a later system that re-checks readiness every frame
  3. In tests, use PipelineCache::block_on_render_pipeline / block_on_compute_pipeline, or call app.update() several times before asserting
  4. If startup takes too long because only a few pipelines compile per frame, reduce the number of queued pipelines (share layouts/shaders) rather than blocking

Example fix

// before
let pipeline = pipeline_cache.get_render_pipeline_state(pipeline_id).unwrap();

// after
if let CachedPipelineState::Ok(pipeline) =
    pipeline_cache.get_render_pipeline_state(pipeline_id)
{
    // build bind groups / record draws
}
Defensive patterns

Strategy: type-guard

Validate before calling

use bevy::render::render_resource::CachedPipelineState;

fn pipeline_is_ready(
    cache: &PipelineCache,
    id: CachedRenderPipelineId,
) -> bool {
    matches!(
        cache.get_render_pipeline_state(id),
        CachedPipelineState::Ok(_)
    )
}

Type guard

fn as_ready_pipeline(
    cache: &PipelineCache,
    id: CachedRenderPipelineId,
) -> Option<&bevy::render::render_resource::Pipeline> {
    match cache.get_render_pipeline_state(id) {
        CachedPipelineState::Ok(p) => Some(p),
        _ => None,
    }
}

Prevention

When it happens

Trigger: Calling pipeline_cache.get_render_pipeline_state(id).unwrap() (or get_compute_pipeline_state().unwrap()) in the same frame the pipeline was queued, or any unwrap() before the pipeline-creation systems pick the task up (only a limited number of pipeline compile tasks are started per frame).

Common situations: Custom render plugins that queue a pipeline and build bind groups / issue draws in the same system or run before the cache advances; integration tests that don't tick the app enough frames; a large shader backlog (many pipelines queued ahead of yours) during startup.

Related errors


AI-assisted analysis of bevyengine/bevy@8d743eb7dc (2026-08-20). Data as JSON: /api/errors/48a037b7622c79b0. Report an issue: GitHub.