stride3d/stride · error · ContentStreamingException
Data chunk is missing or has invalid size.
Error message
Data chunk is missing or has invalid size.
What it means
During image deserialization, each mip level's raw pixel data is stored as a chunk in the ContentStorage. This error is thrown when the chunk for a mip level is absent (GetChunk returned null) or its Size does not match the expected slicePitch * ArraySize computed via Image.ComputePitch. It indicates the serialized texture asset data is corrupt, truncated, or was produced with a mismatched format/size layout.
Solutions
- Re-import/rebuild the texture asset so the storage container is regenerated with correct chunk sizes.
- Verify the ImageDescription (Format, Width, Height, MipLevels, ArraySize) matches what the asset was serialized with; fix format mismatches.
- Check the source asset file is not truncated or corrupted (compare checksums, re-download).
- Clear intermediate/object build caches and rebuild the content pipeline output.
Defensive patterns
Strategy: validation
Validate before calling
var chunk = storage.GetChunk(mipIndex); Image.ComputePitch(format, mipWidth, mipHeight, out _, out int slicePitch, out _, out _); bool valid = chunk != null && chunk.Size == slicePitch * imageDescription.ArraySize;
Type guard
bool HasValidChunk(ContentStorage storage, int mipIndex, int expectedSize) => storage.GetChunk(mipIndex) is { } c && c.Size == expectedSize; Try / catch
try { obj = serializer.Deserialize(context); }
catch (ContentStreamingException ex) when (ex.Message.Contains("Data chunk"))
{
logger.LogError(ex, "Corrupt texture chunk");
// fallback: reload or rebuild asset
} Prevention
- Rebuild assets after Stride version upgrades to keep headers and chunk sizes in sync
- Checksum-verify assets after build/deploy to catch truncation
- Never hand-edit serialized texture containers
- Validate ImageDescription (Format, MipLevels, ArraySize) matches the producing build
When it happens
Trigger: Calling DeserializeImage (during texture Serialize/deserialization pipeline) with a storage whose chunk for mipIndex is missing, or a chunk whose byte size differs from slicePitch*ArraySize for the ImageDescription's format and mip dimensions.
Common situations: Asset files truncated by bad uploads or interrupted builds; texture assets serialized with an older Stride version or different pixel format than the descriptor expects; hand-edited or corrupted data containers; storage header pointing to the wrong asset.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Missing content storage.
- Data chunk is missing or has invalid size.
- Data chunk is not loaded.
- Trying to serialize a Texture without CPU info.
- Two different classes have the same DataContract Alias
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/1f7a234f23eff426.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Data/ImageTextureSerializer.cs:105
var buffer = MemoryUtilities.Allocate(size);
try
{
// Load image data to the buffer
var bufferPtr = buffer;
for (int arrayIndex = 0; arrayIndex < imageDescription.ArraySize; arrayIndex++)
{
for (int mipIndex = 0; mipIndex < imageDescription.MipLevels; mipIndex++)
{
var (mipWidth, mipHeight) = Image.GetMipDimensions(format, imageDescription.Width, imageDescription.Height, mipIndex);
int rowPitch, slicePitch;
int widthPacked;
int heightPacked;
Image.ComputePitch(format, mipWidth, mipHeight, out rowPitch, out slicePitch, out widthPacked, out heightPacked);
var chunk = storage.GetChunk(mipIndex);
if (chunk == null || chunk.Size != slicePitch * imageDescription.ArraySize)
throw new ContentStreamingException("Data chunk is missing or has invalid size.", storage);
var data = chunk.GetData(fileProvider);
if (!chunk.IsLoaded)
throw new ContentStreamingException("Data chunk is not loaded.", storage);
MemoryUtilities.CopyWithAlignmentFallback((void*)bufferPtr, (void*)data, (uint)chunk.Size);
bufferPtr += chunk.Size;
}
}
// Initialize image
var image = new Image(imageDescription, buffer, 0, null, true);
obj.InitializeFrom(image);
}
catch
{
// Free memory in case of error
MemoryUtilities.Free(buffer);
View on GitHub (pinned to 96fad776d2)