{"record":{"id":"efc6fb0884944f54","repo":"BabylonJS/Babylon.js","slug":"material-material-name-effect-is-not-ready-w","errorCode":null,"errorMessage":"Material \"${material.name}\" effect is not ready. Wait for it to be rendered.","messagePattern":"Material \"(.+?)\" effect is not ready\\. Wait for it to be rendered\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/shaderCommandService.ts","lineNumber":49,"sourceCode":"                }\r\n\r\n                const id = parseInt(args.uniqueId, 10);\r\n                if (isNaN(id)) {\r\n                    throw new Error(\"uniqueId must be a number.\");\r\n                }\r\n\r\n                const material = scene.materials.find((m) => m.uniqueId === id);\r\n                if (!material) {\r\n                    throw new Error(`No material found with uniqueId ${id}.`);\r\n                }\r\n\r\n                const effect = material.getEffect();\r\n                if (!effect) {\r\n                    throw new Error(`Material \"${material.name}\" has no effect. It may not have been rendered yet.`);\r\n                }\r\n\r\n                if (!effect.isReady()) {\r\n                    throw new Error(`Material \"${material.name}\" effect is not ready. Wait for it to be rendered.`);\r\n                }\r\n\r\n                const variant = args.variant ?? \"compiled\";\r\n\r\n                let vertexShader: string;\r\n                let fragmentShader: string;\r\n\r\n                switch (variant) {\r\n                    case \"compiled\":\r\n                        vertexShader = effect.vertexSourceCode;\r\n                        fragmentShader = effect.fragmentSourceCode;\r\n                        break;\r\n                    case \"raw\":\r\n                        vertexShader = effect.rawVertexSourceCode;\r\n                        fragmentShader = effect.rawFragmentSourceCode;\r\n                        break;\r\n                    case \"beforeMigration\":\r\n                        vertexShader = effect.vertexSourceCodeBeforeMigration;\r","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/shaderCommandService.ts#L31-L67","documentation":"This error is thrown by the inspector CLI `get-shader-code` command when the material's compiled Effect exists but its GPU program has not finished compiling/linking yet (effect.isReady() is false). Babylon.js compiles shaders asynchronously, so an effect can be non-null while still not ready to execute. The command refuses to return shader source until the pipeline is ready.","triggerScenarios":"Calling get-shader-code with a valid material uniqueId immediately after creating the material or assigning it to a mesh, before the first frame that uses the material has been rendered (shader still compiling, or shader compilation failed and never became ready).","commonSituations":"Querying shaders right after scene setup without rendering a frame; material created but never bound to an active mesh; shader compilation error keeping isReady() false forever; headless/CLI usage where no render loop runs to drive compilation.","solutions":["Render at least one frame with the material active, then retry the command","Wait for readiness via scene.executeWhenReady() or the material's onCompiled callback / effect.getPipelineContext() readiness before calling get-shader-code","Ensure the material is actually assigned to a mesh that is in the camera frustum / enabled so Babylon compiles its effect","Check for shader compilation errors in the console (a failed compile leaves the effect never-ready); fix the shader or material configuration","Use scene.whenReadyAsync() in headless flows before running CLI inspection commands"],"exampleFix":"// before\nconst code = await cli.run(\"get-shader-code\", { uniqueId: \"123\" });\n// after\nawait scene.whenReadyAsync();\nscene.render();\nconst code = await cli.run(\"get-shader-code\", { uniqueId: \"123\" });","handlingStrategy":"validation","validationCode":"const material = scene.materials.find((m) => m.uniqueId === id);\nconst effect = material?.getEffect();\nif (!effect || !effect.isReady()) {\n    await scene.whenReadyAsync();\n    scene.render(); // force one frame so the effect compiles\n}","typeGuard":"function isEffectReady(material: BABYLON.Material | undefined): material is BABYLON.Material & { getEffect(): BABYLON.Effect } {\n    const effect = material?.getEffect();\n    return !!effect && effect.isReady();\n}","tryCatchPattern":"try {\n    const code = await cli.run(\"get-shader-code\", { uniqueId });\n} catch (err) {\n    if (String(err).includes(\"effect is not ready\")) {\n        await scene.whenReadyAsync();\n        return retryGetShaderCode(uniqueId);\n    }\n    throw err;\n}","preventionTips":["Call scene.whenReadyAsync() before inspecting shader code","Render at least one frame after material creation before querying its effect","Verify the material is assigned to an active, visible mesh so its effect gets compiled","Watch for shader compilation errors, which leave effects permanently not-ready"],"tags":["shader","async","material","rendering"],"backgroundTag":"shader-not-ready","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}