unoplatform/uno · critical · Exception

Program link failed: {infoLog}

Error message

Program link failed: {infoLog}

What it means

CreateProgram in QuerySyncGlCanvasElement links the bars and probe shader pairs and throws when link status is not True. Same mechanism as errors 83 and 86; here it applies to _barsProgram (instanced bars, uWave[8] + uPalette[4] uniforms) and _probeProgram (uRect vec4 + uColor vec4 uniforms).

Source

Thrown at src/SamplesApp/SamplesApp.Samples/Windows_UI_Composition/QuerySyncGlCanvasElement.cs:279

			// --- Fence this frame's commands and kick the GPU ---
			_frameSync = gl.FenceSync(SyncCondition.SyncGpuCommandsComplete, (SyncBehaviorFlags)0);
			gl.Flush();

			Invalidate();
		}

		private static uint CreateProgram(GL gl, string vertexSource, string fragmentSource)
		{
			var vs = CompileShader(gl, ShaderType.VertexShader, vertexSource);
			var fs = CompileShader(gl, ShaderType.FragmentShader, fragmentSource);
			var prog = gl.CreateProgram();
			gl.AttachShader(prog, vs);
			gl.AttachShader(prog, fs);
			gl.LinkProgram(prog);
			gl.GetProgram(prog, ProgramPropertyARB.LinkStatus, out int linkStatus);
			if (linkStatus != (int)GLEnum.True)
			{
				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));
			}

View on GitHub (pinned to 0418340488)

Solutions

  1. Read the appended info log to find the specific unresolved interface or exceeded limit.
  2. Confirm both stages of the failing program received the same versionDef.
  3. Check the bars program's total uniform component count (uWave = 8 floats, uPalette = 12 floats) against gl.Get(MAX_VERTEX_UNIFORM_COMPONENTS) — low-end GLES contexts may have limits around 256-1024.
  4. Verify the vertex `out`/fragment `in` declarations match exactly (name + type) for the bars program.
  5. Link bars and probe programs separately and report which one failed.

Example fix

// before
if (linkStatus != (int)GLEnum.True)
    throw new Exception("Program link failed: " + gl.GetProgramInfoLog(prog));

// after — name the failing program in the message
if (linkStatus != (int)GLEnum.True)
    throw new Exception($"Program link failed (caller: {new System.Diagnostics.StackFrame(1).GetMethod().Name}): {gl.GetProgramInfoLog(prog)}");
Defensive patterns

Strategy: validation

Validate before calling

// Confirm both stages share versionDef and that uniform component count fits limits
if (!vertexSource.StartsWith(versionDef) || !fragmentSource.StartsWith(versionDef)) return;
gl.GetInteger(GetPName.MaxVertexUniformComponents, out int maxVertUniforms);
// bars program: uWave(8) + uPalette(12) = 20 floats — well under typical 1024+ limit
if (maxVertUniforms < 32) return; // tight context; link may fail

Try / catch

try { _barsProgram = CreateProgram(gl, barsVs, barsFs); }
catch (Exception ex) when (ex.Message.Contains("Program link failed"))
{
    App.MainWindow?.LogError($"Bars program link failed: {ex.Message}");
    _barsProgram = 0;
}

Prevention

When it happens

Trigger: After AttachShader + LinkProgram for either the bars program or the probe program, gl.GetProgram(LinkStatus) != True (lines 276-279). The info log is appended.

Common situations: Bars vertex shader outputs `out vec3 vColor` while fragment declares `in vec3 vColor` (these match, but a typo would link-fail); the probe vertex shader has no `out` and the probe fragment has no `in` so the interface is trivially empty — a link failure here usually means a stage-level issue like too many uniform components (uWave[8] + uPalette[12] floats may approach per-stage uniform limits on low-end contexts); versionDef mismatch between the bars VS and bars FS; array uniform declaration mismatch between stages.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/ae13bc863320cf8c. Report an issue: GitHub.