{"record":{"id":"ec22a0b9850dccec","repo":"zed-industries/zed","slug":"it-s-the-caller-s-job-to-pass-a-valid-frame-index","errorCode":null,"errorMessage":"It's the caller's job to pass a valid frame index","messagePattern":"It's the caller's job to pass a valid frame index","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/window.rs","lineNumber":4778,"sourceCode":"            color: color.opacity(element_opacity),\n            tile,\n            transformation,\n        });\n\n        Ok(())\n    }\n\n    /// Paint an image into the scene for the next frame at the current z-index.\n    /// This method will panic if the frame_index is not valid\n    ///\n    /// This method should only be called as part of the paint phase of element drawing.\n    /// Paint an image into `bounds`, positioning and scaling it according to `image_bounds`.\n    ///\n    /// The visible region rendered is `bounds.intersect(&image_bounds)`, with `corner_radii`\n    /// applied to `bounds`.\n    pub fn paint_image(\n        &mut self,\n        bounds: Bounds<Pixels>,\n        image_bounds: Bounds<Pixels>,\n        corner_radii: Corners<Pixels>,\n        data: Arc<RenderImage>,\n        frame_index: usize,\n        grayscale: bool,\n    ) -> Result<()> {\n        self.invalidator.debug_assert_paint();\n\n        let visible_bounds = bounds.intersect(&image_bounds);\n        if visible_bounds.size.width <= Pixels::ZERO || visible_bounds.size.height <= Pixels::ZERO {\n            return Ok(());\n        }\n        if image_bounds.size.width <= Pixels::ZERO || image_bounds.size.height <= Pixels::ZERO {\n            return Ok(());\n        }\n\n        let params = RenderImageParams {\n            image_id: data.id,","sourceCodeStart":4760,"sourceCodeEnd":4796,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/window.rs#L4760-L4796","documentation":"When rendering an image frame into the sprite atlas, data.as_bytes(frame_index) is expected to succeed because the caller passed a valid frame index (bounds were checked just above). Panicking means an out-of-range frame index reached this function — a caller-side contract violation for RenderImage frame data.","triggerScenarios":"Thrown at crates/gpui/src/window.rs:4524 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure callers only pass frame_index values within the image's frame count","Validate frame_index at the API boundary before paint","Check image decoders producing inconsistent frame counts vs as_bytes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}