{"record":{"id":"8c051a2ca2e86fad","repo":"stride3d/stride","slug":"data-chunk-is-missing-or-has-invalid-size-8c051a","errorCode":null,"errorMessage":"Data chunk is missing or has invalid size.","messagePattern":"Data chunk is missing or has invalid size\\.","errorType":"exception","errorClass":"ContentStreamingException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Data/TextureContentSerializer.cs","lineNumber":170,"sourceCode":"                var format = imageDescription.Format;\n                var dataBoxes = new DataBox[imageDescription.MipLevels * imageDescription.ArraySize];\n                int dataBoxIndex = 0;\n\n                // Get data boxes data\n                for (int arrayIndex = 0; arrayIndex < imageDescription.ArraySize; arrayIndex++)\n                {\n                    for (int mipIndex = 0; mipIndex < imageDescription.MipLevels; mipIndex++)\n                    {\n                        var (mipWidth, mipHeight) = Image.GetMipDimensions(format, imageDescription.Width, imageDescription.Height, mipIndex);\n\n                        int rowPitch, slicePitch;\n                        int widthPacked;\n                        int heightPacked;\n                        Image.ComputePitch(format, mipWidth, mipHeight, out rowPitch, out slicePitch, out widthPacked, out heightPacked);\n\n                        var chunk = storage.GetChunk(mipIndex);\n                        if (chunk == null || chunk.Size != slicePitch * imageDescription.ArraySize)\n                            throw new ContentStreamingException(\"Data chunk is missing or has invalid size.\", storage);\n                        var data = chunk.GetData(fileProvider);\n                        if (!chunk.IsLoaded)\n                            throw new ContentStreamingException(\"Data chunk is not loaded.\", storage);\n\n                        dataBoxes[dataBoxIndex].DataPointer = data + slicePitch * arrayIndex;\n                        dataBoxes[dataBoxIndex].RowPitch = rowPitch;\n                        dataBoxes[dataBoxIndex].SlicePitch = slicePitch;\n                        dataBoxIndex++;\n                    }\n                }\n\n                // Initialize texture\n                texture.InitializeFrom(imageDescription, new TextureViewDescription(), dataBoxes);\n\n                storage.UnlockChunks();\n            }\n        }\n    }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Data/TextureContentSerializer.cs#L152-L188","documentation":"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.","triggerScenarios":"Calling DeserializeTexture when storage.GetChunk(mipIndex) returns null or a chunk whose Size != slicePitch * ArraySize for the mip dimensions and format.","commonSituations":"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.","solutions":["Rebuild the texture asset through the content pipeline to regenerate correctly sized chunks.","Confirm the ImageDescription/StorageHeader (Format, MipLevels, ArraySize, dimensions) matches the data actually stored.","Re-download/re-copy the asset and verify integrity (checksum) to rule out truncation.","Clear cached content and rebuild packages after upgrading Stride versions."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var chunk = storage.GetChunk(mipIndex);\nImage.ComputePitch(format, mipWidth, mipHeight, out _, out int slicePitch, out _, out _);\nbool ok = chunk != null && chunk.Size == slicePitch * imageDescription.ArraySize;\nif (!ok) throw new InvalidOperationException($\"Mip {mipIndex} chunk missing/invalid: got {chunk?.Size ?? -1}, expected {slicePitch * imageDescription.ArraySize}.\");","typeGuard":"bool IsValidTextureChunk(StorageChunk chunk, int expectedSize) => chunk != null && chunk.Size == expectedSize;","tryCatchPattern":"try\n{\n    texture = DeserializeTexture(stream, context, ref storageHeader);\n}\ncatch (ContentStreamingException ex)\n{\n    log.Error(ex, \"Texture mip chunk missing or wrong size; rebuilding asset\");\n    // trigger asset rebuild or load placeholder\n}","preventionTips":["Regenerate assets whenever format or mip settings change","Verify packaged asset checksums at deployment","Keep content build and runtime Stride versions aligned","Test loading all texture assets after pipeline upgrades"],"tags":["content-pipeline","textures","serialization","stride"],"backgroundTag":"schema-validation-failed","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}