bevyengine/bevy · error · TextureAccessError

out of bounds (x: {x}, y: {y}, z: {z})

Error message

out of bounds (x: {x}, y: {y}, z: {z})

What it means

Texture access error variant fired when a caller indexes a pixel with x/y/z coordinates outside the texture's dimensions. x must be < width, y < height, z < depth_layer_or_dimension; any coordinate equal to or beyond its dimension is rejected.

Source

Thrown at crates/bevy_image/src/image.rs:2269

    /// Attempted to access a pixel outside the texture bounds.
    #[error("out of bounds (x: {x}, y: {y}, z: {z})")]
    OutOfBounds {
        /// The pixel x-coordinate.
        x: u32,
        /// The pixel y-coordinate.
        y: u32,
        /// The pixel z-coordinate.
        z: u32,
    },
    /// Attempted to perform an image operation on an unsupported texture format.
    ///
    /// Most often this is returned when attempting to access pixel data of compressed textures.
    #[error("unsupported texture format: {0:?}")]
    UnsupportedTextureFormat(TextureFormat),
    /// Attempted to access the data of an image before it was initialized, or after it was moved
    /// to the GPU.
    ///
    /// See [`RenderAssetUsages`] for more information about when an asset's data is moved, and
    /// how to retain it if necessary.
    #[error("image data is not initialized")]
    Uninitialized,
    /// The texture's dimension was different than indicated by the accessor used.
    #[error("attempt to access texture with different dimension")]
    WrongDimension,
}

/// An error that occurs when loading a texture.
#[derive(Error, Debug)]
pub enum TextureError {
    /// Image MIME type is invalid.
    #[error("invalid image mime type: {0}")]
    InvalidImageMimeType(String),
    /// Image extension is invalid.
    #[error("invalid image extension: {0}")]
    InvalidImageExtension(String),
    /// Failed to load an image.

View on GitHub (pinned to 8d743eb7dc)

Solutions

  1. Clamp coordinates to the image extent before access
  2. Check the image texture_size against the coordinate before indexing
  3. Fix off-by-one errors such as using width instead of width-1 for the max x
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/bevy_image/src/image.rs:2252 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@8d743eb7dc (2026-08-20). Data as JSON: /api/errors/6fe26324c79e9d8e. Report an issue: GitHub.