BabylonJS/Babylon.js · error

Invalid FBX array byte length for ${type}

Error message

Invalid FBX array byte length for ${type}

What it means

Thrown by parseArrayProperty in the FBX binary parser when an uncompressed (encoding===0) array property's declared on-disk byte length (compressedLength) does not match the byte length computed from the element count and element size for the declared type. The parser treats this as corrupt/malformed FBX binary data and aborts rather than silently reading the wrong number of elements.

Source

Thrown at packages/dev/loaders/src/FBX/parsers/fbxBinaryParser.ts:220

    ensureRange(bytes, offset, 12, limit, `FBX array property header for ${type}`);
    const arrayLength = view.getUint32(offset, true);
    const encoding = view.getUint32(offset + 4, true); // 0=raw, 1=zlib
    const compressedLength = view.getUint32(offset + 8, true);
    offset += 12;
    const expectedByteLength = arrayLength * elementSize;
    ensureRange(bytes, offset, compressedLength, limit, `FBX array property data for ${type}`);

    let arrayData: Uint8Array;
    if (encoding === 1) {
        // zlib compressed
        const compressed = bytes.subarray(offset, offset + compressedLength);
        arrayData = inflateZlib(compressed, expectedByteLength);
    } else {
        if (encoding !== 0) {
            throw new Error(`Unsupported FBX array encoding: ${encoding}`);
        }
        if (compressedLength !== expectedByteLength) {
            throw new Error(`Invalid FBX array byte length for ${type}`);
        }
        arrayData = bytes.slice(offset, offset + compressedLength);
    }

    const arrayBuffer = arrayData.buffer.slice(arrayData.byteOffset, arrayData.byteOffset + arrayData.byteLength);

    let value: Float32Array | Float64Array | Int32Array | Uint8Array;
    switch (type) {
        case "float32[]":
            value = new Float32Array(arrayBuffer);
            break;
        case "float64[]":
            value = new Float64Array(arrayBuffer);
            break;
        case "int32[]":
            value = new Int32Array(arrayBuffer);
            break;
        case "boolean[]":

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Re-export the FBX file from the original DCC tool (Blender/Maya/3ds Max) with a current exporter
  2. Verify the file is not truncated or line-ending-mangled in transfer (compare file size/hash with the source)
  3. Open the file in a reference FBX reader (e.g., FBX Converter / fbx-conv) to confirm it is valid
  4. Inspect the offending node record with an FBX hex viewer to see the mismatched length/count fields
  5. If parsing third-party data defensively, catch this error and skip/repair the node rather than failing the whole load

Example fix

// before
catch (e) { throw e; }
// after
try { node = parseFbxBinary(bytes); }
catch (e) {
  if (String(e.message).includes('Invalid FBX array byte length')) {
    console.warn('Corrupt array property in FBX, skipping node'); node = null;
  } else throw e;
}
Defensive patterns

Strategy: validation

Validate before calling

// inside parseArrayProperty, before slicing
const expectedByteLength = count * ELEMENT_SIZES[type];
if (encoding === 0 && compressedLength !== expectedByteLength) {
  throw new Error(`Invalid FBX array byte length for ${type}`);
}

Type guard

function isValidArrayHeader(type: string, count: number, len: number): boolean {
  const size = ELEMENT_SIZES[type];
  return typeof size === 'number' && count >= 0 && len === count * size;
}

Try / catch

try {
  const { property } = parseArrayProperty(bytes, offset, limit);
} catch (e) {
  if ((e as Error).message.startsWith('Invalid FBX array byte length')) {
    reportCorruptAsset(e); return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Parsing an FBX binary node property whose record header declares, e.g., 10 doubles (expectedByteLength=80) but compressedLength=72; a truncated or hand-edited FBX file; a writer that computed element count and byte length inconsistently.

Common situations: FBX files exported by buggy or non-conformant exporters; files corrupted in transfer (e.g., FTP ASCII mode, partial download); files with mismatched/forged array headers after post-processing; older FBX versions written by tools with length bugs.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/2495dcbdf84dd163. Report an issue: GitHub.