bevyengine/bevy · error · CompressedImageSaverError
Cannot compress an uninitialized image
Error message
Cannot compress an uninitialized image
What it means
CompressedImageSaverError::UninitializedImage: the CompressedImageSaver was asked to compress an Image whose data buffer is not yet initialized (e.g. created with uninit data and never filled), which compression cannot handle.
Source
Thrown at crates/bevy_image/src/compressed_image_saver/mod.rs:212
Straight,
/// The image has an alpha channel, and the RGB channels have been premultiplied by the alpha value.
Premultiplied,
/// The image has no alpha channel.
Opaque,
}
/// Errors encountered when writing compressed images via [`CompressedImageSaver`].
#[non_exhaustive]
#[derive(Debug, Error, TypePath)]
pub enum CompressedImageSaverError {
/// I/O error.
#[error(transparent)]
Io(#[from] std::io::Error),
/// The underlying compression library returned an error.
#[error(transparent)]
CompressionFailed(Box<dyn core::error::Error + Send + Sync>),
/// Attempted to save an image with uninitialized data.
#[error("Cannot compress an uninitialized image")]
UninitializedImage,
/// The texture format is not supported for compression.
#[error("Unsupported texture format for compression: {0:?}")]
UnsupportedFormat(TextureFormat),
/// `is_normal_map` was set, but the input [`Image`]'s `texture_descriptor.format` is an sRGB
/// variant (e.g. `Rgba8UnormSrgb`). Normal maps must be stored as linear vector data. Typically this means
/// configuring the [`ImageLoaderSettings`] with `is_srgb: false` for this image.
#[error(
"Cannot compress an sRGB texture ({0:?}) as a normal map; \
the input Image's texture_descriptor.format must be a non-sRGB (linear) variant"
)]
NormalMapMustBeLinear(TextureFormat),
}
View on GitHub (pinned to 396ca72708)
Solutions
- Fully write the image pixel data before saving
- Avoid RenderAssetUsages/main-thread patterns that leave image data uninit when saving
- Handle the Result from the asset writer and report the faulty asset
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/bevy_image/src/compressed_image_saver/mod.rs:212 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/ceb70696d0c84389.
Report an issue: GitHub.