{"record":{"id":"9c4c4b9738886d34","repo":"BabylonJS/Babylon.js","slug":"failed-to-read-frame-time","errorCode":null,"errorMessage":"Failed to read frame time.","messagePattern":"Failed to read frame time\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":383,"sourceCode":"    // number of frames\n    const numFrames = parseInt(framesTokens[1]);\n    if (isNaN(numFrames)) {\n        throw new Error(\"Failed to read number of frames.\");\n    }\n    context.numFrames = numFrames;\n\n    // frame time\n    const frameTimeLine = lines.shift();\n    if (!frameTimeLine) {\n        throw new Error(\"Unexpected end of file before frame time\");\n    }\n    const frameTimeTokens = frameTimeLine.trim().split(/[\\s]+/);\n    if (frameTimeTokens.length < 3) {\n        throw new Error(\"Invalid frame time line\");\n    }\n    const frameTime = parseFloat(frameTimeTokens[2]);\n    if (isNaN(frameTime)) {\n        throw new Error(\"Failed to read frame time.\");\n    }\n    if (frameTime <= 0) {\n        throw new Error(\"Failed to read frame time. Invalid value \" + frameTime);\n    }\n\n    context.frameRate = 1 / frameTime;\n\n    // read frame data line by line\n    for (let i = 0; i < numFrames; ++i) {\n        const frameLine = lines.shift();\n        if (!frameLine) {\n            continue;\n        }\n        const tokens = frameLine.trim().split(/[\\s]+/) || [];\n        ReadFrameData(tokens, i, root, { i: 0 });\n    }\n\n    context.root = root;","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L365-L401","documentation":"After extracting the third token of the frame-time line, ReadBvh parses it with parseFloat and throws this error when the result is NaN, meaning the token in the value position is not a valid number.","triggerScenarios":"A frame-time line like 'Frame Time: abc' or 'Frame Time: 1/30' where the third token cannot be parsed as a float; also occurs when a stray non-numeric token sits in the value position after whitespace splitting.","commonSituations":"Files corrupted by find-and-replace, locale-formatted values ('0,033' with comma decimal separator in some exports), manually typed garbage in the header, or templated BVH files with unfilled placeholders.","solutions":["Check the frame-time value in the file and replace it with a plain decimal number using a dot separator, e.g. 'Frame Time: 0.033333'","Convert comma decimal separators to dots if the file came from a locale that formats numbers with commas","Re-export the BVH from the source application if the header value is corrupted","Validate the Frame Time line with a regex like /^Frame Time:\\s+[0-9.]+e?-?[0-9]*$/i before parsing"],"exampleFix":"// before\nFrame Time: 0,033333\n// after\nFrame Time: 0.033333","handlingStrategy":"validation","validationCode":"function validateFrameTimeValue(text) {\n  const m = text.match(/^Frame Time:\\s*([^\\s]+)\\s*$/im);\n  if (!m || isNaN(parseFloat(m[1]))) {\n    throw new Error('Frame Time value is not a valid decimal number');\n  }\n}","typeGuard":"function isParsableFrameTime(text: string): boolean {\n  const m = text.match(/^Frame Time:\\s*([^\\s]+)\\s*$/im);\n  return !!m && !isNaN(parseFloat(m[1]));\n}","tryCatchPattern":"try {\n  skeleton.readBvh(text);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to read frame time.') {\n    console.error('Frame Time value is not numeric; use dot-decimal like 0.033333');\n  } else throw e;\n}","preventionTips":["Always write frame times as dot-decimal numbers, never locale formats with commas","Sanitize BVH files generated by tools that localize number formatting","Reject files whose header values fail /^\\d+(\\.\\d+)?([eE][-+]?\\d+)?$/ before parsing"],"tags":["bvh","parsing","nan","number-format"],"backgroundTag":"invalid-number-format","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}