{"record":{"id":"9817b9af80e364fc","repo":"unoplatform/uno","slug":"fragment-shader-failed-to-compile-infolog","errorCode":null,"errorMessage":"Fragment shader failed to compile: {infoLog}","messagePattern":"Fragment shader failed to compile: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/SimpleTriangleGlCanvasElement.cs","lineNumber":89,"sourceCode":"\n\t\t\tuint vertexShader = gl.CreateShader(ShaderType.VertexShader);\n\t\t\tgl.ShaderSource(vertexShader, vertexCode);\n\t\t\tgl.CompileShader(vertexShader);\n\n\t\t\tgl.GetShader(vertexShader, ShaderParameterName.CompileStatus, out int vStatus);\n\t\t\tif (vStatus != (int)GLEnum.True)\n\t\t\t{\n\t\t\t\tthrow new Exception(\"Vertex shader failed to compile: \" + gl.GetShaderInfoLog(vertexShader));\n\t\t\t}\n\n\t\t\tuint fragmentShader = gl.CreateShader(ShaderType.FragmentShader);\n\t\t\tgl.ShaderSource(fragmentShader, fragmentCode);\n\t\t\tgl.CompileShader(fragmentShader);\n\n\t\t\tgl.GetShader(fragmentShader, ShaderParameterName.CompileStatus, out int fStatus);\n\t\t\tif (fStatus != (int)GLEnum.True)\n\t\t\t{\n\t\t\t\tthrow new Exception(\"Fragment shader failed to compile: \" + gl.GetShaderInfoLog(fragmentShader));\n\t\t\t}\n\n\t\t\t_program = gl.CreateProgram();\n\t\t\tgl.AttachShader(_program, vertexShader);\n\t\t\tgl.AttachShader(_program, fragmentShader);\n\t\t\tgl.LinkProgram(_program);\n\n\t\t\tgl.GetProgram(_program, ProgramPropertyARB.LinkStatus, out int lStatus);\n\t\t\tif (lStatus != (int)GLEnum.True)\n\t\t\t{\n\t\t\t\tthrow new Exception(\"Program failed to link: \" + gl.GetProgramInfoLog(_program));\n\t\t\t}\n\n\t\t\tgl.DetachShader(_program, vertexShader);\n\t\t\tgl.DetachShader(_program, fragmentShader);\n\t\t\tgl.DeleteShader(vertexShader);\n\t\t\tgl.DeleteShader(fragmentShader);\n\t\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/SimpleTriangleGlCanvasElement.cs#L71-L107","documentation":"Sibling of the vertex-shader check: thrown when the fragment shader's CompileStatus is not True. The fragment source uses the same versionDef and a 'precision highp float' line plus 'in vec4 vertexColor', so it fails for the same driver/version reasons, plus stage-specific issues (varying/in qualifier mismatch, unsupported precision in the fragment stage).","triggerScenarios":"gl.CompileShader on the fragment shader on a context where the fragment GLSL is invalid: e.g. 'highp' not supported in fragment stage on older GLES2 hardware, the versionDef is '#version 330' while the context is ES, or 'in' is rejected because the context is pre-3.00.","commonSituations":"Same Skia GL host as the vertex error but it surfaces here because fragment-stage highp is the stricter constraint; mobile/low-end GPUs that advertise ES 2.0 only; a driver bug where the vertex shader compiles but the fragment does not due to precision limits.","solutions":["Read the info log in the message to get the exact fragment-shader line/error.","Replace 'precision highp float;' with 'precision mediump float;' — highp is optional in the fragment stage on many GLES devices.","Confirm versionDef is correct for the context (see vertex-shader error); an ES context forced to '#version 330' fails here too.","Verify the context is GLES 3.0 / GL 3.3 so 'in vec4 vertexColor' and '#version 300 es' are valid.","On headless Linux, provide a working GL context (software rasterizer or GPU passthrough)."],"exampleFix":"// before\nprecision highp float; // for OpenGL ES compatibility\n// after - use mediump which is guaranteed in the fragment stage\nprecision mediump float;","handlingStrategy":"validation","validationCode":"// Fragment stage highp is optional; validate capability\nint range[2], precision;\ngl.GetShaderPrecisionFormat(ShaderType.FragmentShader, ShaderParameterName.HighFloat, out range[0], out range[1], out precision);\nbool highpFrag = precision > 0;\nvar fragHeader = highpFrag ? \"precision highp float;\" : \"precision mediump float;\";","typeGuard":null,"tryCatchPattern":"try { gl.CompileShader(fragmentShader); }\ncatch (Exception ex) when (ex.Message.Contains(\"Fragment shader failed to compile\"))\n{\n    _log.Error($\"Fragment GLSL compile failed: {ex.Message}\");\n}","preventionTips":["Prefer mediump in the fragment stage for cross-device compatibility.","Share the version directive logic with the vertex shader so they stay consistent.","Validate shader precision format for the fragment stage before compiling."],"tags":["opengl","glsl","shader","skia","graphics","samples"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}