siyuan-note/siyuan · error · Error
Unable to compile graph shader
Error message
Unable to compile graph shader
What it means
createShader() throws when gl.COMPILE_STATUS is false after gl.compileShader. The message is gl.getShaderInfoLog output, falling back to 'Unable to compile graph shader'. A compile failure is a hard GLSL syntax/type error in the inline NODE_/EDGE_/ARROW_ shader source.
Source
Thrown at app/src/layout/dock/graph/webglRenderer.ts:497
gl.deleteShader(vertex);
gl.deleteShader(fragment);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const message = gl.getProgramInfoLog(program) || "Unable to link graph shader";
gl.deleteProgram(program);
throw new Error(message);
}
return program;
}
private createShader(type: number, source: string) {
const gl = this.gl;
const shader = this.requireValue(gl.createShader(type));
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const message = gl.getShaderInfoLog(shader) || "Unable to compile graph shader";
gl.deleteShader(shader);
throw new Error(message);
}
return shader;
}
private getUniform(program: WebGLProgram, name: string) {
return this.requireValue(this.gl.getUniformLocation(program, name));
}
private requireValue<T>(value: T | null): T {
if (value === null) {
throw new Error("Unable to allocate graph rendering resource");
}
return value;
}
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Read the thrown info log — it points at the line and column of the compile error.
- Cross-check the edited shader string against GLSL ES 3.00 rules (version directive first, precision, in/out qualifiers).
- Compile-test on a reference desktop GPU to isolate driver-specific GLSL quirks.
- If a feature (e.g. fwidth) is unavailable, add the required #extension directive or fall back to a non-derivatives path.
Example fix
// before
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
throw new Error(gl.getShaderInfoLog(shader) || 'Unable to compile graph shader');
}
// after
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const log = gl.getShaderInfoLog(shader);
console.error('shader compile failed:', log, '\nin source:\n', source);
gl.deleteShader(shader);
throw new Error('Graph shader compile failed; see console for GLSL info log');
} Defensive patterns
Strategy: try-catch
Try / catch
try { return new WebGLRenderer(canvas); }
catch (e) {
if (/compile/i.test(e.message)) console.error('GLSL compile error:', e.message);
showGraphFallback();
return null;
} Prevention
- Compile-test edited GLSL on a reference GPU and read the info log line numbers.
- Use GLSL ES 3.00 syntax (in/out, precision qualifiers) consistently.
- Add #extension directives when using features like derivatives (fwidth).
- Avoid hand-minifying shader sources; keep them readable for compiler diagnostics.
When it happens
Trigger: Editing the inline GLSL ES 3.00 shader strings (typo, undeclared variable, type mismatch, using WebGL1-only built-ins), or running on a driver that does not implement a GLSL feature the source assumes (e.g. fwidth without derivatives extension).
Common situations: Refactor of the shader source introduces a syntax error; copy-paste between WebGL1 and WebGL2 shaders leaves legacy syntax; precision qualifier missing on a new float uniform; bundled shader minifier mangles the source.
Related errors
- Unable to link graph shader
- WebGL2 is unavailable
- Unable to allocate graph rendering resource
- Canvas 2D is unavailable
- Failed to save agent session
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/5c27e652c88e8dca.
Report an issue: GitHub.