{"record":{"id":"abd5f0e543d76c67","repo":"BabylonJS/Babylon.js","slug":"failed-to-read-frame-time-invalid-value","errorCode":null,"errorMessage":"Failed to read frame time. Invalid value ","messagePattern":"Failed to read frame time\\. Invalid value ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/BVH/bvhLoader.ts","lineNumber":386,"sourceCode":"        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;\n\n    ConvertNode(context.root, null, context);\n","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/BVH/bvhLoader.ts#L368-L404","documentation":"ReadBvh requires the frame time to be a positive number since it computes frameRate = 1 / frameTime. This error is thrown when parseFloat succeeds but the value is zero or negative, which would produce a non-finite or negative frame rate.","triggerScenarios":"A frame-time line such as 'Frame Time: 0' or 'Frame Time: -0.033' in the BVH file; also a template file where the value placeholder was replaced with 0.","commonSituations":"Auto-generated BVH with an uninitialized frame-time variable, hand-edited files where the value was zeroed out, or corrupted exports where the header value was overwritten with a default/sentinel.","solutions":["Set the frame time to a positive value in seconds, e.g. 'Frame Time: 0.033333' (30 fps)","Compute the correct value as 1 / desiredFps from the source animation's frame rate","Re-export the BVH from the original animation tool so the header is regenerated correctly","Validate that the parsed frame time is > 0 before calling ReadBvh when processing untrusted files"],"exampleFix":"// before\nFrame Time: 0\n// after\nFrame Time: 0.033333","handlingStrategy":"validation","validationCode":"function validateFrameTimePositive(text) {\n  const m = text.match(/^Frame Time:\\s*([^\\s]+)\\s*$/im);\n  const ft = m ? parseFloat(m[1]) : NaN;\n  if (!(ft > 0)) throw new Error('Frame Time must be > 0, got ' + ft);\n}","typeGuard":"function isPositiveFrameTime(text: string): boolean {\n  const m = text.match(/^Frame Time:\\s*([^\\s]+)\\s*$/im);\n  const ft = m ? parseFloat(m[1]) : NaN;\n  return Number.isFinite(ft) && ft > 0;\n}","tryCatchPattern":"try {\n  skeleton.readBvh(text);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to read frame time. Invalid value')) {\n    console.error('Frame Time must be a positive number of seconds');\n  } else throw e;\n}","preventionTips":["Initialize frame-time variables to a valid default (e.g. 1/30) in BVH generators","Assert frameTime > 0 when exporting animation data to BVH","Validate BVH headers in CI with a lightweight pre-parse check"],"tags":["bvh","parsing","invalid-value","division-by-zero"],"backgroundTag":"invalid-parameter-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}