{"record":{"id":"e83abf092cf2eac6","repo":"BabylonJS/Babylon.js","slug":"shader-error-typeof-message-string-n","errorCode":null,"errorMessage":"SHADER ERROR\" + (typeof message === \"string\" ? \"\\n\" + message : \"\")","messagePattern":"SHADER ERROR\" \\+ \\(typeof message === \"string\" \\? \"\\\\n\" \\+ message : \"\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/Native/nativePipelineContext.ts","lineNumber":24,"sourceCode":"import { type AbstractEngine } from \"../abstractEngine\";\r\nimport { type NativeShaderProcessingContext } from \"./nativeShaderProcessingContext\";\r\nimport { type ThinNativeEngine } from \"../thinNativeEngine\";\r\n\r\nexport class NativePipelineContext implements IPipelineContext {\r\n    public isCompiled: boolean = false;\r\n    public compilationError?: Error;\r\n\r\n    public readonly isAsync: boolean;\r\n\r\n    public program: NativeProgram;\r\n\r\n    public vertexBufferKindToType: { [kind: string]: number } = {};\r\n    public shaderProcessingContext: Nullable<NativeShaderProcessingContext>;\r\n\r\n    public get isReady(): boolean {\r\n        if (this.compilationError) {\r\n            const message = this.compilationError.message;\r\n            throw new Error(\"SHADER ERROR\" + (typeof message === \"string\" ? \"\\n\" + message : \"\"));\r\n        }\r\n        return this.isCompiled;\r\n    }\r\n\r\n    public onCompiled?: () => void;\r\n\r\n    public _getVertexShaderCode(): string | null {\r\n        return null;\r\n    }\r\n\r\n    public _getFragmentShaderCode(): string | null {\r\n        return null;\r\n    }\r\n\r\n    private _engine: ThinNativeEngine;\r\n    private _valueCache: { [key: string]: any } = {};\r\n    private _uniforms: { [key: string]: Nullable<WebGLUniformLocation> };\r\n\r","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/Native/nativePipelineContext.ts#L6-L42","documentation":"NativePipelineContext.isReady rethrows a recorded shader compilation failure: if compilationError was set during shader compilation, accessing isReady throws 'SHADER ERROR' plus the compiler's message. It surfaces GLSL/WGSL compile/link problems at the point where the engine checks pipeline readiness.","triggerScenarios":"Accessing pipelineContext.isReady (directly or via effect readiness checks) after a shader failed to compile in Babylon Native, e.g. due to shader code syntax errors, unsupported uniforms, or a bad ShaderStore/shader path.","commonSituations":"Typos in custom ShaderMaterial GLSL; referencing uniforms/varyings unsupported by the native backend; shader name misspelled so empty/invalid source is compiled; custom shader code ported from WebGL that the native compiler rejects.","solutions":["Read the appended compiler message in the thrown error and fix the shader source at the reported line.","Check that the shader name/path resolves in ShaderStore (effect.assets/shaders include) and the shader actually compiled.","Test the shader with the same code path on the WebGL engine to isolate native-specific incompatibilities."],"exampleFix":"// before\nconst shader = \"myShders\"; // misspelled path -> invalid shader\nnew ShaderMaterial(\"m\", scene, shader, {});\n// after\nconst shader = \"myShaders/myShader\";\nnew ShaderMaterial(\"m\", scene, shader, {});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  if (!pipelineContext.isReady) { /* wait */ }\n} catch (e) {\n  if (String(e.message).startsWith('SHADER ERROR')) {\n    console.error('Shader compilation failed:\\n' + e.message); // includes compiler output\n    // fix shader source / path, or fall back to a known-good shader\n  } else throw e;\n}","preventionTips":["Validate custom shader code on the WebGL engine before running on NativeEngine.","Ensure shader names/paths exist in ShaderStore so the compiler receives real source.","Log compilationError early (effect.onCompiled / onError) instead of polling isReady blindly.","Keep uniform/varying usage within what the native backend supports."],"tags":["babylonjs","shader-compile","native-engine","gpu"],"backgroundTag":"shader-compilation-failed","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}