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

  1. Run start-perf-instrumentation before calling get-frame-stats
  2. If the scene changed, re-run start-perf-instrumentation to create fresh instrumentation for the new scene
  3. Reorder automation scripts so get-frame-stats only runs after a successful start-perf-instrumentation
  4. 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

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


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