unoplatform/uno · critical · Exception
{type} compile failed: {infoLog}
Error message
{type} compile failed: {infoLog} What it means
CompileShader in QuerySyncGlCanvasElement throws when a stage fails to compile, before linking. Applies to the bars vertex/fragment sources (with uWave[8], uPalette[4], gl_InstanceID-based instancing) and the probe vertex/fragment sources (uRect, uColor).
Source
Thrown at src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/QuerySyncGlCanvasElement.cs:296
{
throw new Exception("Program link failed: " + gl.GetProgramInfoLog(prog));
}
gl.DetachShader(prog, vs);
gl.DetachShader(prog, fs);
gl.DeleteShader(vs);
gl.DeleteShader(fs);
return prog;
}
private static uint CompileShader(GL gl, ShaderType type, string source)
{
var sh = gl.CreateShader(type);
gl.ShaderSource(sh, source);
gl.CompileShader(sh);
gl.GetShader(sh, ShaderParameterName.CompileStatus, out int status);
if (status != (int)GLEnum.True)
{
throw new Exception($"{type} compile failed: " + gl.GetShaderInfoLog(sh));
}
return sh;
}
}
}
#endif
View on GitHub (pinned to 0418340488)
Solutions
- Read the appended infoLog for line-precise diagnostics.
- Confirm gl.GetStringS(StringName.ShadingLanguageVersion) reports a version that supports gl_InstanceID (GLES 3.00+ / WebGL2 / desktop 1.50+); on older contexts the bars instancing shader cannot compile and needs a different instancing strategy or attribute-based indexing.
- For contexts lacking gl_InstanceID, pass the instance index as a vertex attribute or use gl_VertexID-based derivation where supported.
- Move `precision highp float` declarations to the fragment stage only, or declare vertex-stage precision explicitly per-float-type as the driver requires.
- Validate offline with glslangValidator targeting the matching GLSL version.
Example fix
// before
if (status != (int)GLEnum.True)
throw new Exception($"{type} compile failed: " + gl.GetShaderInfoLog(sh));
// after — guard version capabilities before compiling and surface source
if (versionDef == "#version 300 es" && !slVersion.Contains("3.0"))
throw new Exception($"Context does not support GLSL ES 3.00 (has {slVersion}); instancing shader requires it.");
if (status != (int)GLEnum.True)
{
var log = gl.GetShaderInfoLog(sh);
throw new Exception($"{type} compile failed (versionDef={versionDef}): {log}");
} Defensive patterns
Strategy: validation
Validate before calling
// Confirm the context supports instancing (gl_InstanceID) before compiling the bars VS
var sl = gl.GetStringS(StringName.ShadingLanguageVersion);
if (sl.Contains("OpenGL ES") && !sl.Contains("3.")) return; // #version 300 es unsupported; cannot use gl_InstanceID
if (!source.StartsWith("#version 300 es") && source.Contains("gl_InstanceID")) return; Try / catch
try { sh = CompileShader(gl, type, source); }
catch (Exception ex) when (ex.Message.Contains("compile failed"))
{
App.MainWindow?.LogError($"{type} compile failed (QuerySync): {ex.Message}");
sh = 0;
} Prevention
- Confirm ShadingLanguageVersion supports gl_InstanceID (GLES 3.00+ / WebGL2 / desktop 1.50+).
- On older contexts, pass the instance index as a vertex attribute instead of gl_InstanceID.
- Move precision declarations off the vertex stage where rejected.
- Validate offline with glslangValidator targeting the matching GLSL version.
When it happens
Trigger: Inside CompileShader after CompileShader, gl.GetShader(CompileStatus) != True (lines 290-296). The bars VS uses `float i = float(gl_InstanceID);` and dynamically indexes uWave[gl_InstanceID], which requires GLSL ES 3.00 / desktop 1.50+.
Common situations: versionDef selected `#version 300 es` but the context is GLES 2.0 / WebGL1 where gl_InstanceID and dynamic array indexing in the vertex shader are unavailable; `precision highp float` rejected on the vertex stage of a context that lacks highp in the vertex shader; the modulo arithmetic `gl_InstanceID - (gl_InstanceID / 4) * 4` triggers an integer-division precision warning that escalates to an error under strict compilation; layout(location=0) qualifiers rejected on GLSL ES 1.00.
Related errors
- {type} compile failed: {infoLog}
- {type} compile failed: {infoLog}
- Error compiling shader of type {type}, failed with error {in
- Program link failed: {infoLog}
- {name} uniform not found on shader.
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/3efcdccc91bea438.
Report an issue: GitHub.