{"record":{"id":"155829e1697c66b7","repo":"bevyengine/bevy","slug":"failed-to-update-perspectiveprojection-width-and","errorCode":null,"errorMessage":"Failed to update PerspectiveProjection: width and height must be positive, non-zero values","messagePattern":"Failed to update PerspectiveProjection: width and height must be positive, non-zero values","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_camera/src/projection.rs","lineNumber":391,"sourceCode":"        let x = (2.0 * self.near) / (right_prime - left_prime);\n        let y = (2.0 * self.near) / (top_prime - bottom_prime);\n        let a = (right_prime + left_prime) / (right_prime - left_prime);\n        let b = (top_prime + bottom_prime) / (top_prime - bottom_prime);\n\n        let mut matrix = Mat4::from_cols(\n            Vec4::new(x, 0.0, 0.0, 0.0),\n            Vec4::new(0.0, y, 0.0, 0.0),\n            Vec4::new(a, b, 0.0, -1.0),\n            Vec4::new(0.0, 0.0, self.near, 0.0),\n        );\n\n        self.adjust_perspective_matrix_for_clip_plane(&mut matrix);\n        matrix\n    }\n\n    fn update(&mut self, width: f32, height: f32) {\n        self.aspect_ratio = AspectRatio::try_new(width, height)\n            .expect(\"Failed to update PerspectiveProjection: width and height must be positive, non-zero values\")\n            .ratio();\n    }\n\n    fn far(&self) -> f32 {\n        self.far\n    }\n\n    fn get_frustum_corners(&self, z_near: f32, z_far: f32) -> [Vec3A; 8] {\n        let tan_half_fov = ops::tan(self.fov / 2.);\n        let a = z_near.abs() * tan_half_fov;\n        let b = z_far.abs() * tan_half_fov;\n        let aspect_ratio = self.aspect_ratio;\n        // NOTE: These vertices are in the specific order required by [`calculate_cascade`].\n        [\n            Vec3A::new(a * aspect_ratio, -a, z_near),  // bottom right\n            Vec3A::new(a * aspect_ratio, a, z_near),   // top right\n            Vec3A::new(-a * aspect_ratio, a, z_near),  // top left\n            Vec3A::new(-a * aspect_ratio, -a, z_near), // bottom left","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_camera/src/projection.rs#L373-L409","documentation":"Raised by PerspectiveProjection::update when the viewport or render-target dimensions passed in are zero or negative, making the computed aspect-dependent projection terms (frustum widths/heights) invalid. The projection matrix cannot be sensibly built from such dimensions.","triggerScenarios":"Thrown at crates/bevy_camera/src/projection.rs:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the window/render target has non-zero width and height before the camera renders","Delay camera activation until the window is sized","Guard code that resizes targets to zero (minimized window)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}