BabylonJS/Babylon.js · error · Error
Failed to read frame time. Invalid value
Error message
Failed to read frame time. Invalid value
What it means
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.
Source
Thrown at packages/dev/loaders/src/BVH/bvhLoader.ts:386
throw new Error("Failed to read number of frames.");
}
context.numFrames = numFrames;
// frame time
const frameTimeLine = lines.shift();
if (!frameTimeLine) {
throw new Error("Unexpected end of file before frame time");
}
const frameTimeTokens = frameTimeLine.trim().split(/[\s]+/);
if (frameTimeTokens.length < 3) {
throw new Error("Invalid frame time line");
}
const frameTime = parseFloat(frameTimeTokens[2]);
if (isNaN(frameTime)) {
throw new Error("Failed to read frame time.");
}
if (frameTime <= 0) {
throw new Error("Failed to read frame time. Invalid value " + frameTime);
}
context.frameRate = 1 / frameTime;
// read frame data line by line
for (let i = 0; i < numFrames; ++i) {
const frameLine = lines.shift();
if (!frameLine) {
continue;
}
const tokens = frameLine.trim().split(/[\s]+/) || [];
ReadFrameData(tokens, i, root, { i: 0 });
}
context.root = root;
ConvertNode(context.root, null, context);
View on GitHub (pinned to 0592b347b8)
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
Example fix
// before Frame Time: 0 // after Frame Time: 0.033333
Defensive patterns
Strategy: validation
Validate before calling
function validateFrameTimePositive(text) {
const m = text.match(/^Frame Time:\s*([^\s]+)\s*$/im);
const ft = m ? parseFloat(m[1]) : NaN;
if (!(ft > 0)) throw new Error('Frame Time must be > 0, got ' + ft);
} Type guard
function isPositiveFrameTime(text: string): boolean {
const m = text.match(/^Frame Time:\s*([^\s]+)\s*$/im);
const ft = m ? parseFloat(m[1]) : NaN;
return Number.isFinite(ft) && ft > 0;
} Try / catch
try {
skeleton.readBvh(text);
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to read frame time. Invalid value')) {
console.error('Frame Time must be a positive number of seconds');
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.
Related errors
- Unexpected end of file before frame time
- Invalid frame time line
- Failed to read frame time.
- Nothing else parsed so far
- Invalid JSON Format. Check the frame values and make sure t
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/abd5f0e543d76c67.
Report an issue: GitHub.