{"record":{"id":"a9207c44e4fd86f1","repo":"bevyengine/bevy","slug":"pipeline-has-not-been-compiled-yet-it-is-still-in-a9207c","errorCode":null,"errorMessage":"Pipeline has not been compiled yet. It is still in the 'Creating' state.","messagePattern":"Pipeline has not been compiled yet\\. It is still in the 'Creating' state\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_render/src/render_resource/pipeline_cache.rs","lineNumber":77,"sourceCode":"impl CachedPipelineState {\n    /// Convenience method to \"unwrap\" a pipeline state into its underlying GPU object.\n    ///\n    /// # Returns\n    ///\n    /// The method returns the allocated pipeline GPU object.\n    ///\n    /// # Panics\n    ///\n    /// This method panics if the pipeline GPU object is not available, either because it is\n    /// pending creation or because an error occurred while attempting to create GPU object.\n    pub fn unwrap(&self) -> &Pipeline {\n        match self {\n            CachedPipelineState::Ok(pipeline) => pipeline,\n            CachedPipelineState::Queued => {\n                panic!(\"Pipeline has not been compiled yet. It is still in the 'Queued' state.\")\n            }\n            CachedPipelineState::Creating(..) => {\n                panic!(\"Pipeline has not been compiled yet. It is still in the 'Creating' state.\")\n            }\n            CachedPipelineState::Err(err) => panic!(\"{}\", err),\n        }\n    }\n}\n\n// The default webgpu `max_bind_groups` is 4. Most desktop GPUs support 8.\n// Since the element size we used below is small, we inline 8 on the stack.\nconst BIND_GROUP_LAYOUTS_INLINE_CAPACITY: usize = 8;\n\ntype ImmediateSize = u32;\ntype LayoutCacheKey = (\n    SmallVec<[BindGroupLayoutId; BIND_GROUP_LAYOUTS_INLINE_CAPACITY]>,\n    ImmediateSize,\n);\n\nwgpu_wrapper! {\n    struct WgpuPipelineLayout(PipelineLayout);","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/bevyengine/bevy/blob/8d743eb7dc7fcff57a7d5744d0bbf89620b1b145/crates/bevy_render/src/render_resource/pipeline_cache.rs#L59-L95","documentation":"CachedPipelineState::unwrap() panics when the pipeline is in the 'Creating' state: the creation Task<Result<Pipeline, ShaderCacheError>> is currently running but has not finished. Unlike 'Queued', the task already started (shader compilation / pipeline creation in progress); unwrap() still fails because the GPU object is not available yet.","triggerScenarios":"Calling get_render_pipeline_state(id).unwrap() (or get_compute_pipeline_state().unwrap()) during the frames while the pipeline compile task is executing — typically one to a few frames after queueing, or on machines with slow shader compilation.","commonSituations":"First frames after app startup when shaders are still compiling; heavy scenes with many pipelines; CI machines or web builds where compilation is slow; code that worked locally because compilation finished fast but races on slower hardware.","solutions":["Match on the state and skip drawing while it is Creating/Queued: if let CachedPipelineState::Ok(pipeline) = ...","Defer pipeline-dependent work to a system that runs every frame and checks readiness, instead of a one-shot initialization system","In tests, call PipelineCache::block_on_render_pipeline / block_on_compute_pipeline or advance the app several update() ticks","Keep an initialization resource/flag that flips only once the pipeline reports Ok so dependent systems gate on it"],"exampleFix":"// before\nlet pipeline = pipeline_cache.get_render_pipeline_state(pipeline_id).unwrap();\n\n// after\nmatch pipeline_cache.get_render_pipeline_state(pipeline_id) {\n    CachedPipelineState::Ok(pipeline) => { /* build bind groups / draw */ }\n    CachedPipelineState::Err(err) => { error!(\"pipeline failed: {err}\"); }\n    _ => { /* still Queued/Creating: skip this frame */ }\n}","handlingStrategy":"type-guard","validationCode":"use bevy::render::render_resource::CachedPipelineState;\n\nfn pipeline_is_ready(\n    cache: &PipelineCache,\n    id: CachedRenderPipelineId,\n) -> bool {\n    matches!(\n        cache.get_render_pipeline_state(id),\n        CachedPipelineState::Ok(_)\n    )\n}","typeGuard":"fn as_ready_pipeline(\n    cache: &PipelineCache,\n    id: CachedRenderPipelineId,\n) -> Option<&bevy::render::render_resource::Pipeline> {\n    match cache.get_render_pipeline_state(id) {\n        CachedPipelineState::Ok(p) => Some(p),\n        _ => None, // Queued, Creating, or Err\n    }\n}","tryCatchPattern":null,"preventionTips":["Treat 'pipeline not ready on frame N' as a normal state: skip drawing and retry next frame","Log CachedPipelineState::Err variants so failed compiles surface instead of looking like an infinite Creating loop","Order pipeline-consuming systems after the cache-updating systems each frame"],"tags":["bevy","render-pipeline","shader-compilation","async","panic"],"backgroundTag":"async-resource-not-ready","analyzedSha":"8d743eb7dc7fcff57a7d5744d0bbf89620b1b145","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}