{"record":{"id":"c69ce026367d4668","repo":"BabylonJS/Babylon.js","slug":"performance-instrumentation-is-not-running-run-st","errorCode":null,"errorMessage":"Performance instrumentation is not running. Run start-perf-instrumentation first.","messagePattern":"Performance instrumentation is not running\\. Run start-perf-instrumentation first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/statsCommandService.ts","lineNumber":118,"sourceCode":"                        activeParticles: scene.getActiveParticles(),\r\n                        drawCalls: scene.getEngine()._drawCalls.current,\r\n                        totalLights: scene.lights.length,\r\n                        totalVertices: scene.getTotalVertices(),\r\n                        totalMaterials: scene.materials.length,\r\n                        totalTextures: scene.textures.length,\r\n                    },\r\n                    null,\r\n                    2\r\n                );\r\n            },\r\n        });\r\n\r\n        const frameStatsReg = commandRegistry.addCommand({\r\n            id: \"get-frame-stats\",\r\n            description: \"Get frame timing statistics. Requires start-perf-instrumentation to be run first.\",\r\n            executeAsync: async () => {\r\n                if (!sceneInstrumentation || !engineInstrumentation) {\r\n                    throw new Error(\"Performance instrumentation is not running. Run start-perf-instrumentation first.\");\r\n                }\r\n\r\n                const si = sceneInstrumentation;\r\n                const ei = engineInstrumentation;\r\n\r\n                const round = (v: number) => Math.round(v * 100) / 100;\r\n\r\n                return JSON.stringify(\r\n                    {\r\n                        absoluteFPS: Math.floor(1000.0 / si.frameTimeCounter.lastSecAverage),\r\n                        meshesSelectionMs: round(si.activeMeshesEvaluationTimeCounter.lastSecAverage),\r\n                        renderTargetsMs: round(si.renderTargetsRenderTimeCounter.lastSecAverage),\r\n                        particlesMs: round(si.particlesRenderTimeCounter.lastSecAverage),\r\n                        spritesMs: round(si.spritesRenderTimeCounter.lastSecAverage),\r\n                        animationsMs: round(si.animationsTimeCounter.lastSecAverage),\r\n                        physicsMs: round(si.physicsTimeCounter.lastSecAverage),\r\n                        renderMs: round(si.renderTimeCounter.lastSecAverage),\r\n                        frameMs: round(si.frameTimeCounter.lastSecAverage),\r","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/statsCommandService.ts#L100-L136","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst stats = await cli.run(\"get-frame-stats\", {});\n// after\nawait cli.run(\"start-perf-instrumentation\", {});\n// ... collect frames ...\nconst stats = await cli.run(\"get-frame-stats\", {});","handlingStrategy":"retry","validationCode":"const hasInstrumentation =\n    sceneInstrumentation != null && !sceneInstrumentation.scene.isDisposed && engineInstrumentation != null;\nif (!hasInstrumentation) {\n    await cli.run(\"start-perf-instrumentation\", {});\n}","typeGuard":"function isInstrumentationRunning(si: BABYLON.SceneInstrumentation | null, ei: BABYLON.EngineInstrumentation | null): boolean {\n    return si != null && ei != null && !si.scene.isDisposed;\n}","tryCatchPattern":"try {\n    return await cli.run(\"get-frame-stats\", {});\n} catch (err) {\n    if (String(err).includes(\"instrumentation is not running\")) {\n        await cli.run(\"start-perf-instrumentation\", {});\n        return cli.run(\"get-frame-stats\", {});\n    }\n    throw err;\n}","preventionTips":["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"],"tags":["instrumentation","cli","prerequisite","performance"],"backgroundTag":"instrumentation-not-started","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}