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

In DeserializeTexture, each mip level's data must be provided as a chunk whose Size equals slicePitch * ArraySize computed from the ImageDescription. This error is thrown when the chunk for a mip is missing (null) or its size doesn't match that expectation, so the DataBoxes for the texture cannot be populated safely. Same family as the ImageTextureSerializer variant but for the Texture path.

Solutions

  1. Rebuild the texture asset through the content pipeline to regenerate correctly sized chunks.
  2. Confirm the ImageDescription/StorageHeader (Format, MipLevels, ArraySize, dimensions) matches the data actually stored.
  3. Re-download/re-copy the asset and verify integrity (checksum) to rule out truncation.
  4. Clear cached content and rebuild packages after upgrading Stride versions.
Defensive patterns

Strategy: validation

Validate before calling

var chunk = storage.GetChunk(mipIndex);
Image.ComputePitch(format, mipWidth, mipHeight, out _, out int slicePitch, out _, out _);
bool ok = chunk != null && chunk.Size == slicePitch * imageDescription.ArraySize;
if (!ok) throw new InvalidOperationException($"Mip {mipIndex} chunk missing/invalid: got {chunk?.Size ?? -1}, expected {slicePitch * imageDescription.ArraySize}.");

Type guard

bool IsValidTextureChunk(StorageChunk chunk, int expectedSize) => chunk != null && chunk.Size == expectedSize;

Try / catch

try
{
    texture = DeserializeTexture(stream, context, ref storageHeader);
}
catch (ContentStreamingException ex)
{
    log.Error(ex, "Texture mip chunk missing or wrong size; rebuilding asset");
    // trigger asset rebuild or load placeholder
}

Prevention

When it happens

Trigger: Calling DeserializeTexture when storage.GetChunk(mipIndex) returns null or a chunk whose Size != slicePitch * ArraySize for the mip dimensions and format.

Common situations: Corrupt/truncated packaged assets; assets rebuilt with a different format or mip count than the header describes; manual stream serialization that wrote wrong chunk sizes; version mismatch between writer and reader.

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


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/8c051a2ca2e86fad. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Graphics/Data/TextureContentSerializer.cs:170

                var format = imageDescription.Format;
                var dataBoxes = new DataBox[imageDescription.MipLevels * imageDescription.ArraySize];
                int dataBoxIndex = 0;

                // Get data boxes data
                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);

                        dataBoxes[dataBoxIndex].DataPointer = data + slicePitch * arrayIndex;
                        dataBoxes[dataBoxIndex].RowPitch = rowPitch;
                        dataBoxes[dataBoxIndex].SlicePitch = slicePitch;
                        dataBoxIndex++;
                    }
                }

                // Initialize texture
                texture.InitializeFrom(imageDescription, new TextureViewDescription(), dataBoxes);

                storage.UnlockChunks();
            }
        }
    }

View on GitHub (pinned to 96fad776d2)