BabylonJS/Babylon.js · error · Error
status.error_msg()
Error message
status.error_msg()
What it means
DecodeMesh calls the native Draco decoder's DecodeBufferToMesh on a TRIANGULAR_MESH geometry and throws an Error whose message is the native status string when the status is not ok or the returned mesh pointer is null. The actual text comes straight from the Draco decoder (status.error_msg()), so it varies per failure.
Source
Thrown at packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts:205
const decoderModule = module as DecoderModule;
let decoder: Nullable<Decoder> = null;
let buffer: Nullable<DecoderBuffer> = null;
let geometry: Nullable<Mesh | PointCloud> = null;
try {
decoder = new decoderModule.Decoder();
buffer = new decoderModule.DecoderBuffer();
buffer.Init(data, data.byteLength);
let status: Status;
const type = decoder.GetEncodedGeometryType(buffer);
switch (type) {
case decoderModule.TRIANGULAR_MESH: {
const mesh = new decoderModule.Mesh();
status = decoder.DecodeBufferToMesh(buffer, mesh);
if (!status.ok() || mesh.ptr === 0) {
throw new Error(status.error_msg());
}
const numFaces = mesh.num_faces();
const numIndices = numFaces * 3;
const byteLength = numIndices * 4;
const ptr = decoderModule._malloc(byteLength);
try {
decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);
const indices = new Uint32Array(numIndices);
indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));
onIndicesData(indices);
} finally {
decoderModule._free(ptr);
}
geometry = mesh;
break;
View on GitHub (pinned to 0592b347b8)
Solutions
- Verify the input buffer is complete, uncorrupted Draco-compressed mesh data (check file size/checksum).
- Match the Draco decoder module version to the version used for encoding.
- Confirm the data is a triangular mesh, not a point cloud (POINT_CLOUD takes a different branch).
- Catch this in the worker host and surface status.error_msg() alongside the byte range/source of the buffer to diagnose.
Example fix
// before
await DracoCompression.DecodeMeshToGeometryAsync(name, scene, bufferOfUnknownOrigin);
// after
if (!isDracoBuffer(buffer) || buffer.byteLength === 0) {
throw new Error('Refusing to decode: buffer is not valid Draco data');
}
await DracoCompression.DecodeMeshToGeometryAsync(name, scene, buffer); Defensive patterns
Strategy: validation
Validate before calling
if (!(data instanceof ArrayBuffer) || data.byteLength < 20) {
throw new Error('invalid Draco mesh payload: too small or wrong type');
} Type guard
const isNonEmptyBuffer = (d: unknown): d is ArrayBuffer => d instanceof ArrayBuffer && d.byteLength > 0;
Try / catch
try {
geometry = await DracoCompression.DecodeMeshToGeometryAsync(name, scene, buffer);
} catch (e) {
console.error('Draco mesh decode failed:', e?.message); // includes native status.error_msg()
geometry = null; // fall back to uncompressed asset
} Prevention
- Verify asset integrity (size/checksum) before decoding; handle partial downloads.
- Keep the draco_decoder module version aligned with the encoder version.
- Confirm mesh vs point-cloud payloads are routed to the right decode path.
- Always keep an uncompressed fallback asset or re-fetch path.
When it happens
Trigger: Passing a buffer that is not valid Draco TRIANGULAR_MESH data, truncated/corrupted Draco data, data encoded with an incompatible Draco version, or data that is a point cloud being decoded as a mesh.
Common situations: Serving .draco/glTF files with wrong Content-Type causing corruption; incomplete downloads; Draco WASM/JS decoder version mismatch with encoder version; attempting to decode an arbitrary binary file as Draco.
Related errors
- Draco codec module is not available
- Draco: Failed to encode.
- Draco: Cannot decode invalid geometry type ${type}
- Draco: Cannot decode invalid data type ${dataType}
- Draco: Encoder module is not available
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/45fabd46e8babb1c.
Report an issue: GitHub.