BabylonJS/Babylon.js · error · Error
Draco: Decoder module is not available
Error message
Draco: Decoder module is not available
What it means
DracoDecoder.decodeMeshToMeshDataAsync throws when `dracoCompression.Configuration.decoder` is not marked available (no decoder module configured/loaded), so there is no DracoDecoderModule instance to decode with. It guards the decode entry point on the main thread before dispatching to workers.
Source
Thrown at packages/dev/core/src/Meshes/Compression/dracoDecoder.ts:220
resultIndices = indices;
},
(kind, data, size, byteOffset, byteStride, normalized) => {
resultAttributes.push({
kind,
data,
size,
byteOffset,
byteStride,
normalized,
});
}
);
return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };
});
}
throw new Error("Draco: Decoder module is not available");
}
/**
* Decode Draco compressed mesh data to Babylon geometry.
* @param name The name to use when creating the geometry
* @param scene The scene to use when creating the geometry
* @param data The ArrayBuffer or ArrayBufferView of the Draco compressed data
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
* @returns A promise that resolves with the decoded geometry
*/
public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {
const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);
const geometry = new Geometry(name, scene);
if (meshData.indices) {
geometry.setIndices(meshData.indices);
}
for (const attribute of meshData.attributes) {
geometry.setVerticesBuffer(
View on GitHub (pinned to 0592b347b8)
Solutions
- Configure the decoder before use: `DracoCompression.Configuration.decoder = { url: "<path>/draco_decoder.js", wasmUrl: ... }` and ensure the URL loads.
- Preload/await the decoder module (e.g. trigger an init or `whenReadyAsync`) before decoding any Draco data.
- Check `DracoCompression.Configuration.decoder?.available` before calling decode and load on demand if false.
- Fallback: skip Draco decode path if the module can't load (decode uncompressed geometry instead).
Example fix
// before
const data = await DracoCompression.DecodeMeshToMeshDataAsync(drcData);
// after
if (!DracoCompression.Configuration.decoder) {
DracoCompression.Configuration.decoder = { url: "https://cdn.babylonjs.com/draco/draco_decoder.js" };
}
await firstObservedPromise; // ensure decoder module finished loading
const data = await DracoCompression.DecodeMeshToMeshDataAsync(drcData); Defensive patterns
Strategy: validation
Validate before calling
if (!DracoCompression.Configuration.decoder || !DracoCompression.Configuration.decoder.available) {
DracoCompression.Configuration.decoder = { url: "https://cdn.babylonjs.com/draco/draco_decoder.js" };
await ensureDecoderLoaded();
} Type guard
function canDecodeDraco(): boolean {
return !!DracoCompression.Configuration.decoder?.available;
} Try / catch
try {
return await DracoCompression.DecodeMeshToMeshDataAsync(data);
} catch (e) {
if (e instanceof Error && e.message.includes("Decoder module is not available")) {
await loadDracoDecoder();
return await DracoCompression.DecodeMeshToMeshDataAsync(data);
}
throw e;
} Prevention
- Set decoder config once in a bootstrap module imported before any Draco asset loads
- Preload the decoder during app startup/loading screen
- Gate decode calls behind a decoder-ready promise
- Monitor failed WASM/script fetches (offline/CSP) in error reporting
When it happens
Trigger: Calling `DracoCompression.DecodeMeshToMeshDataAsync` (or `.decodeMeshToMeshDataAsync`) while `DracoCompression.Configuration.decoder` is undefined/null or its `.available` flag is false.
Common situations: Forgetting to load the Draco decoder script (default CDN unreachable/offline PWA), stripping the decoder config in bundled builds, or an awaited decode running before the configuration object finished loading the WASM.
Related errors
- Draco codec module is not available
- Draco: Decoder module is not available
- Draco: Encoder module is not available
- ${context}: ${error.message}
- Atmosphere is not supported on WebGL ${engine.version}.
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/0667f7ca2bf59d60.
Report an issue: GitHub.