{"record":{"id":"f75da88c4fc7e50a","repo":"bevyengine/bevy","slug":"rendertarget-window-missing-window-make-su","errorCode":null,"errorMessage":"RenderTarget::Window missing ({window:?}): Make sure the provided entity has a Window component.","messagePattern":"RenderTarget::Window missing \\((.+?)\\): Make sure the provided entity has a Window component\\.","errorType":"exception","errorClass":"MissingRenderTargetInfoError","httpStatus":null,"severity":"error","filePath":"crates/bevy_render/src/camera.rs","lineNumber":332,"sourceCode":"        &self,\n        changed_window_ids: &EntityHashSet,\n        changed_image_handles: &HashSet<&AssetId<Image>>,\n    ) -> bool {\n        match self {\n            NormalizedRenderTarget::Window(window_ref) => {\n                changed_window_ids.contains(&window_ref.entity())\n            }\n            NormalizedRenderTarget::Image(image_target) => {\n                changed_image_handles.contains(&image_target.handle.id())\n            }\n            NormalizedRenderTarget::TextureView(_) | NormalizedRenderTarget::None { .. } => true,\n        }\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum MissingRenderTargetInfoError {\n    #[error(\"RenderTarget::Window missing ({window:?}): Make sure the provided entity has a Window component.\")]\n    Window { window: Entity },\n    #[error(\"RenderTarget::Image missing ({image:?}): Make sure the Image's usages include RenderAssetUsages::MAIN_WORLD.\")]\n    Image { image: AssetId<Image> },\n    #[error(\"RenderTarget::TextureView missing ({texture_view:?}): make sure the texture view handle was not removed.\")]\n    TextureView {\n        texture_view: ManualTextureViewHandle,\n    },\n}\n\n/// System in charge of updating a [`Camera`] when its window or projection changes.\n///\n/// The system detects window creation, resize, and scale factor change events to update the camera\n/// [`Projection`] if needed.\n///\n/// ## World Resources\n///\n/// [`Res<Assets<Image>>`](Assets<Image>) -- For cameras that render to an image, this resource is used to\n/// inspect information about the render target. This system will not access any other image assets.","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/bevyengine/bevy/blob/8d743eb7dc7fcff57a7d5744d0bbf89620b1b145/crates/bevy_render/src/camera.rs#L314-L350","documentation":"`get_render_target_info` (behind `Camera::target_info`) resolves a camera's `RenderTarget` into a `RenderTargetInfo` and returns `MissingRenderTargetInfoError` when the target cannot be found. The `Window` variant fires when `RenderTarget::Window(entity)` names an entity that is not among the extracted `(Entity, &Window)` pairs: the entity has no `Window` component or was despawned.","triggerScenarios":"Reading `camera.target_info(...)` (directly or through systems that consume RenderTargetInfo) while the camera's target entity lacks a `Window` component, references a despawned window, or before the window exists.","commonSituations":"Spawning a camera with `target: RenderTarget::Window(entity.into())` where the entity is a plain spawned entity that never got a Window; despawning a window without retargeting its cameras.","solutions":["Ensure the entity used in `RenderTarget::Window` is an actual window (spawned with a `Window` component)","Use the primary window or `Camera::default()` targeting when you only have one window","When despawning windows, update or despawn cameras that still target them first"],"exampleFix":"// before\nlet entity = commands.spawn_empty().id();\ncamera.target = RenderTarget::Window(entity.into()); // entity has no Window\n\n// after\nlet entity = commands.spawn(Window::default()).id();\ncamera.target = RenderTarget::Window(entity.into());","handlingStrategy":"try-catch","validationCode":"// before assigning a camera target\nif world.get::<Window>(target_entity).is_some() {\n    camera.target = RenderTarget::Window(target_entity.into());\n} else {\n    warn!(\"entity {target_entity} has no Window component; using primary window\");\n    camera.target = RenderTarget::Window(primary_window_entity.into());\n}","typeGuard":"fn target_window_exists(\n    target: &RenderTarget,\n    windows: &Query<(Entity, &Window)>,\n) -> bool {\n    match target {\n        RenderTarget::Window(w) => windows.get(w.entity()).is_ok(),\n        _ => true,\n    }\n}","tryCatchPattern":"match camera.target_info(windows, images, manual_texture_views) {\n    Ok(info) => { /* use info */ }\n    Err(MissingRenderTargetInfoError::Window { window }) => {\n        warn!(\"camera target window {window:?} missing; skipping update\");\n    }\n    Err(other) => { warn!(\"render target problem: {other:?}\"); }\n}","preventionTips":["Only pass entities spawned with a Window component to RenderTarget::Window","Retarget or despawn cameras before despawning their window","Treat target_info as fallible and handle all three MissingRenderTargetInfoError variants"],"tags":["bevy","camera","render-target","window","ecs"],"backgroundTag":"entity-missing-component","analyzedSha":"8d743eb7dc7fcff57a7d5744d0bbf89620b1b145","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}