{"record":{"id":"e26579c5c360c557","repo":"zed-industries/zed","slug":"instance-buffer-needs-required-bytes-above-the","errorCode":null,"errorMessage":"instance buffer needs {required} bytes, above the maximum of {MAX_INSTANCE_BUFFER_SIZE}","messagePattern":"instance buffer needs (.+?) bytes, above the maximum of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_apple/src/metal_renderer.rs","lineNumber":1488,"sourceCode":"    }\n\n    fn write_iter<T>(\n        &mut self,\n        values: impl ExactSizeIterator<Item = T>,\n    ) -> Result<InstanceBinding> {\n        let (binding, destination) = self.allocate::<T>(values.len())?;\n        for (slot, value) in destination.iter_mut().zip(values) {\n            slot.write(value);\n        }\n        Ok(binding)\n    }\n\n    fn grow(&mut self, required: usize) -> Result<()> {\n        let mut pool = self.pool.lock();\n        let buffer_size = (pool.buffer_size * 2)\n            .max(required.next_power_of_two())\n            .min(MAX_INSTANCE_BUFFER_SIZE);\n        anyhow::ensure!(\n            buffer_size >= required,\n            \"instance buffer needs {required} bytes, above the maximum of {MAX_INSTANCE_BUFFER_SIZE}\"\n        );\n        anyhow::ensure!(\n            buffer_size > self.current.size,\n            \"frame instance data exceeds the {MAX_INSTANCE_BUFFER_SIZE}-byte maximum\"\n        );\n        if buffer_size != pool.buffer_size {\n            log::info!(\"increased instance buffer size to {buffer_size}\");\n            pool.reset(buffer_size);\n        }\n        let buffer = pool.acquire(&self.device, self.unified_memory);\n        drop(pool);\n\n        let filled = mem::replace(&mut self.current, buffer);\n        self.filled.push((filled, self.offset));\n        self.offset = 0;\n        Ok(())","sourceCodeStart":1470,"sourceCodeEnd":1506,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_apple/src/metal_renderer.rs#L1470-L1506","documentation":"ensure! in MetalRenderer's instance buffer grow(): even after doubling the buffer and rounding to the next power of two, the required size cannot fit under MAX_INSTANCE_BUFFER_SIZE; the frame needs more per-instance GPU data than the renderer can allocate.","triggerScenarios":"Thrown at crates/gpui_apple/src/metal_renderer.rs:1481 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce per-frame instance data: split draws into multiple passes/batches","Investigate excessive primitives (text runs, shadows, quads) in one frame","Profile the frame to find the element generating the most instances","If legitimately needed, the MAX_INSTANCE_BUFFER_SIZE limit must be raised in the renderer"],"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"}