{"record":{"id":"2154b80c46175aa6","repo":"unoplatform/uno","slug":"type-compile-failed-infolog-2154b8","errorCode":null,"errorMessage":"{type} compile failed: {infoLog}","messagePattern":"(.+?) compile failed: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/PixelBuffersGlCanvasElement.cs","lineNumber":246,"sourceCode":"\t\t\t{\n\t\t\t\tthrow new Exception(\"Program link failed: \" + gl.GetProgramInfoLog(prog));\n\t\t\t}\n\t\t\tgl.DetachShader(prog, vs);\n\t\t\tgl.DetachShader(prog, fs);\n\t\t\tgl.DeleteShader(vs);\n\t\t\tgl.DeleteShader(fs);\n\t\t\treturn prog;\n\t\t}\n\n\t\tprivate static uint CompileShader(GL gl, ShaderType type, string source)\n\t\t{\n\t\t\tvar sh = gl.CreateShader(type);\n\t\t\tgl.ShaderSource(sh, source);\n\t\t\tgl.CompileShader(sh);\n\t\t\tgl.GetShader(sh, ShaderParameterName.CompileStatus, out int status);\n\t\t\tif (status != (int)GLEnum.True)\n\t\t\t{\n\t\t\t\tthrow new Exception($\"{type} compile failed: \" + gl.GetShaderInfoLog(sh));\n\t\t\t}\n\t\t\treturn sh;\n\t\t}\n\t}\n}\n#endif\n","sourceCodeStart":228,"sourceCodeEnd":253,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/PixelBuffersGlCanvasElement.cs#L228-L253","documentation":"CompileShader in PixelBuffersGlCanvasElement throws when gl.GetShader(CompileStatus) returns non-True, meaning the GLSL compiler rejected the stage. The info log is appended so the syntax/driver error is visible. This is distinct from link failure (error 83) — it fires per-stage before the program is even created.","triggerScenarios":"Inside CompileShader: gl.CreateShader(type) -> gl.ShaderSource -> gl.CompileShader -> gl.GetShader(CompileStatus) != True (lines 240-246). The vertex source is `#version 300 es` or `#version 330` followed by precision highp float, layout(location=0) in vec2 aPos, etc.","commonSituations":"The versionDef detection picked the wrong profile (e.g. desktop `#version 330` selected on a GLES-only context, or `#version 300 es` on WebGL1); `precision highp float` not supported on the vertex stage of a low-end GLES context (some require mediump); layout(location=X) syntax unsupported on GLSL < 330 / GLES < 300; a typo in an identifier that the compiler flags; WebGL rejects `gl_FragColor`-style reserved writes under core profile.","solutions":["Read the appended infoLog — GLSL compiler errors cite a line number and the exact token at fault.","Confirm the versionDef detection: print gl.GetStringS(StringName.ShadingLanguageVersion) and ensure the chosen `#version` directive actually matches the context (GLES contexts report 'OpenGL ES', others use desktop).","If the context is WebGL1/GLES2 (no `#version 300 es`), rewrite the shaders to GLSL ES 1.00 (use gl_FragColor, no layout qualifiers, no in/out — use attribute/varying).","Move `precision highp float;` to fragment-only on GLES contexts that reject it in the vertex stage, or downgrade to mediump where highp is unavailable.","Validate with a reference compiler (e.g. Khronos reference glslang) offline to catch syntax errors before runtime."],"exampleFix":"// before\nif (status != (int)GLEnum.True)\n    throw new Exception($\"{type} compile failed: \" + gl.GetShaderInfoLog(sh));\n\n// after — include source line numbers in the message for faster diagnosis\nif (status != (int)GLEnum.True)\n{\n    var log = gl.GetShaderInfoLog(sh);\n    var numbered = string.Join('\\n', source.Split('\\n').Select((l, i) => $\"{i+1}: {l}\"));\n    throw new Exception($\"{type} compile failed: {log}\\n--- source ---\\n{numbered}\");\n}","handlingStrategy":"validation","validationCode":"// Validate the GLSL version is supported before compiling\nvar sl = gl.GetStringS(StringName.ShadingLanguageVersion);\nvar wantsGles = sl.Contains(\"OpenGL ES\", StringComparison.OrdinalIgnoreCase);\nif (wantsGles && !sl.Contains(\"3.\")) return; // cannot compile #version 300 es here\n// Pre-flight: confirm the source starts with the matching version directive\nif (!source.StartsWith(wantsGles ? \"#version 300 es\" : \"#version 330\")) return;","typeGuard":null,"tryCatchPattern":"try { sh = CompileShader(gl, type, source); }\ncatch (Exception ex) when (ex.Message.Contains(\"compile failed\"))\n{\n    App.MainWindow?.LogError($\"{type} compile failed: {ex.Message}\");\n    sh = 0;\n}","preventionTips":["Read ShadingLanguageVersion and pick the matching #version directive.","Move `precision` declarations to the fragment stage on contexts that reject them in the vertex stage.","Use GLSL ES 1.00 syntax for WebGL1/GLES2 contexts (no layout qualifiers, no in/out).","Validate shader source offline with glslangValidator before runtime."],"tags":["opengl","silk-net","glsl","shader-compile","shader"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}