{"record":{"id":"57401eac04ff7c3c","repo":"bevyengine/bevy","slug":"couldn-t-allocate-space-to-add-the-image-requested","errorCode":null,"errorMessage":"Couldn't allocate space to add the image requested","messagePattern":"Couldn't allocate space to add the image requested","errorType":"exception","errorClass":"DynamicTextureAtlasBuilderError","httpStatus":null,"severity":"error","filePath":"crates/bevy_image/src/dynamic_texture_atlas_builder.rs","lineNumber":12,"sourceCode":"use crate::{Image, TextureAccessError, TextureAtlasLayout, TextureFormatPixelInfo as _};\nuse bevy_asset::RenderAssetUsages;\nuse bevy_math::{URect, UVec2};\nuse guillotiere::{size2, Allocation, AtlasAllocator};\nuse thiserror::Error;\n\n/// An error produced by [`DynamicTextureAtlasBuilder`] when trying to add a new\n/// texture to a [`TextureAtlasLayout`].\n#[derive(Debug, Error)]\npub enum DynamicTextureAtlasBuilderError {\n    /// Unable to allocate space within the atlas for the new texture\n    #[error(\"Couldn't allocate space to add the image requested\")]\n    FailedToAllocateSpace,\n    /// Attempted to add a texture to an uninitialized atlas\n    #[error(\"cannot add texture to uninitialized atlas texture\")]\n    UninitializedAtlas,\n    /// Attempted to add an uninitialized texture to an atlas\n    #[error(\"cannot add uninitialized texture to atlas\")]\n    UninitializedSourceTexture,\n    /// A texture access error occurred\n    #[error(\"texture access error: {0}\")]\n    TextureAccess(#[from] TextureAccessError),\n}\n\n/// Helper utility to update [`TextureAtlasLayout`] on the fly.\n///\n/// Helpful in cases when texture is created procedurally,\n/// e.g: in a font glyph [`TextureAtlasLayout`], only add the [`Image`] texture for letters to be rendered.\npub struct DynamicTextureAtlasBuilder {\n    atlas_allocator: AtlasAllocator,","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_image/src/dynamic_texture_atlas_builder.rs#L1-L30","documentation":"DynamicTextureAtlasBuilderError::FailedToAllocateSpace: the atlas allocator (guillotiere) could not find free space for the new texture within the current atlas size — the atlas is effectively full or too fragmented.","triggerScenarios":"Thrown at crates/bevy_image/src/dynamic_texture_atlas_builder.rs:12 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Grow the atlas (increase initial size / enable resizing in DynamicTextureAtlasBuilder)","Pad/grow the atlas with more empty space before adding","Fail gracefully and let the caller create a new atlas page"],"exampleFix":null,"handlingStrategy":"try-catch","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"}