{"record":{"id":"9f69a635abf5259a","repo":"stride3d/stride","slug":"data-chunk-is-not-loaded-texturecontentserializer","errorCode":null,"errorMessage":"Data chunk is not loaded.","messagePattern":"Data chunk is not loaded\\.","errorType":"exception","errorClass":"ContentStreamingException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Data/TextureContentSerializer.cs","lineNumber":173,"sourceCode":"\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    }\n}\n","sourceCodeStart":155,"sourceCodeEnd":190,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Data/TextureContentSerializer.cs#L155-L190","documentation":"This ContentStreamingException is thrown by TextureContentSerializer.DeserializeTexture when a loaded texture storage chunk's IsLoaded flag is false at deserialize time. The chunk exists and has the correct size, but its raw pixel data has not been (or is no longer) loaded into memory via GetData-compatible loading, so the serializer cannot build DataPointer boxes from it. Stride throws it to fail fast instead of handing a dangling data pointer to the GPU upload path.","triggerScenarios":"Calling content deserialization (via Serialize-driven load pipeline) on a texture whose storage chunk was created but never had its data loaded/kept resident — e.g. chunk.GetData results were discarded, chunks were streamed in lazily, or the chunk was unloaded before DeserializeTexture ran.","commonSituations":"Custom asset pipelines editing .stride texture containers by hand; streaming/paging systems that unload mip chunks then re-run deserialization; content built by tools that wrote chunk metadata but skipped writing/flushing chunk data; race between an async chunk loader and texture deserialization.","solutions":["Ensure chunk.GetData(fileProvider) is called (and its loaded state kept) for every mipIndex before/while DeserializeTexture reads the chunk — the call order in the source loads data then checks IsLoaded, so an unloaded chunk means the storage was not persisted with data","Re-export/rebuild the texture asset with the Stride editor or AssetCompiler so chunks are written with loaded data","If implementing custom IStorage/chunks, make sure Load/GetData populates the chunk and IsLoaded returns true afterwards","Check for code that unloads or disposes chunks between loading the asset and deserializing it"],"exampleFix":"// before\nvar chunk = storage.GetChunk(mipIndex);\nvar data = chunk.GetData(fileProvider); // chunk never actually loaded -> IsLoaded == false\n// after\nvar chunk = storage.GetChunk(mipIndex);\nif (!chunk.IsLoaded)\n    chunk.Load(fileProvider); // or re-fetch storage whose data was persisted\nvar data = chunk.GetData(fileProvider);","handlingStrategy":"validation","validationCode":"var chunk = storage.GetChunk(mipIndex);\nif (chunk == null)\n    throw new InvalidOperationException($\"Missing chunk {mipIndex}\");\nif (!chunk.IsLoaded)\n    chunk.Load(fileProvider); // or delay deserialization until loaded","typeGuard":"bool IsChunkReady(ContentStorageChunk chunk) => chunk != null && chunk.IsLoaded;","tryCatchPattern":"try\n{\n    DeserializeTexture(...);\n}\ncatch (ContentStreamingException ex) when (ex.Message.Contains(\"not loaded\"))\n{\n    // re-load storage chunks, then retry once\n}","preventionTips":["Always call GetData/Load on every mip chunk before deserializing","Do not unload chunks while deserialization is in flight; coordinate with async loaders","Validate custom-built .stride storages in your asset pipeline"],"tags":["graphics","texture","content-pipeline","streaming"],"backgroundTag":"invalid-state-transition","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"}