BabylonJS/Babylon.js · error · Error
Performance instrumentation is not running. Run start-perf-i
Error message
Performance instrumentation is not running. Run start-perf-instrumentation first.
What it means
`get-frame-stats` reports timing data collected by SceneInstrumentation and EngineInstrumentation instances that are created only by `start-perf-instrumentation`. If instrumentation was never started (or was disposed, e.g. when the scene changed), this error is thrown instead of returning empty/stale statistics.
Source
Thrown at packages/dev/inspector-v2/src/services/cli/statsCommandService.ts:118
activeParticles: scene.getActiveParticles(),
drawCalls: scene.getEngine()._drawCalls.current,
totalLights: scene.lights.length,
totalVertices: scene.getTotalVertices(),
totalMaterials: scene.materials.length,
totalTextures: scene.textures.length,
},
null,
2
);
},
});
const frameStatsReg = commandRegistry.addCommand({
id: "get-frame-stats",
description: "Get frame timing statistics. Requires start-perf-instrumentation to be run first.",
executeAsync: async () => {
if (!sceneInstrumentation || !engineInstrumentation) {
throw new Error("Performance instrumentation is not running. Run start-perf-instrumentation first.");
}
const si = sceneInstrumentation;
const ei = engineInstrumentation;
const round = (v: number) => Math.round(v * 100) / 100;
return JSON.stringify(
{
absoluteFPS: Math.floor(1000.0 / si.frameTimeCounter.lastSecAverage),
meshesSelectionMs: round(si.activeMeshesEvaluationTimeCounter.lastSecAverage),
renderTargetsMs: round(si.renderTargetsRenderTimeCounter.lastSecAverage),
particlesMs: round(si.particlesRenderTimeCounter.lastSecAverage),
spritesMs: round(si.spritesRenderTimeCounter.lastSecAverage),
animationsMs: round(si.animationsTimeCounter.lastSecAverage),
physicsMs: round(si.physicsTimeCounter.lastSecAverage),
renderMs: round(si.renderTimeCounter.lastSecAverage),
frameMs: round(si.frameTimeCounter.lastSecAverage),
View on GitHub (pinned to 0592b347b8)
Solutions
- Run start-perf-instrumentation before calling get-frame-stats
- If the scene changed, re-run start-perf-instrumentation to create fresh instrumentation for the new scene
- Reorder automation scripts so get-frame-stats only runs after a successful start-perf-instrumentation
- Track instrumentation lifecycle in your tooling and restart it when it is disposed
Example fix
// before
const stats = await cli.run("get-frame-stats", {});
// after
await cli.run("start-perf-instrumentation", {});
// ... collect frames ...
const stats = await cli.run("get-frame-stats", {}); Defensive patterns
Strategy: retry
Validate before calling
const hasInstrumentation =
sceneInstrumentation != null && !sceneInstrumentation.scene.isDisposed && engineInstrumentation != null;
if (!hasInstrumentation) {
await cli.run("start-perf-instrumentation", {});
} Type guard
function isInstrumentationRunning(si: BABYLON.SceneInstrumentation | null, ei: BABYLON.EngineInstrumentation | null): boolean {
return si != null && ei != null && !si.scene.isDisposed;
} Try / catch
try {
return await cli.run("get-frame-stats", {});
} catch (err) {
if (String(err).includes("instrumentation is not running")) {
await cli.run("start-perf-instrumentation", {});
return cli.run("get-frame-stats", {});
}
throw err;
} Prevention
- Treat start-perf-instrumentation as a mandatory prerequisite in every script that reads frame stats
- Restart instrumentation whenever the active scene changes (it is disposed on scene change)
- Cache a flag when instrumentation starts and reset it on dispose so dependent commands check it first
When it happens
Trigger: Calling get-frame-stats without ever running start-perf-instrumentation; after disposeInstrumentation() ran due to a scene change; after the instrumentation services were disposed on session teardown.
Common situations: Forgetting the required prerequisite command in automation scripts (the command description says start-perf-instrumentation must run first); instrumentation silently disposed after switching scenes; collecting stats in a fresh session before starting instrumentation.
Related errors
- Performance trace is not running. Run start-perf-trace first
- WebGPUDurationMeasure: index out of range (" + index + ")
- Freezing active meshes was cancelled
- Unable to connect to the Inspector bridge on port ${port} af
- Session id must be a number.
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/c69ce026367d4668.
Report an issue: GitHub.