{"record":{"id":"5c27e652c88e8dca","repo":"siyuan-note/siyuan","slug":"unable-to-compile-graph-shader","errorCode":null,"errorMessage":"Unable to compile graph shader","messagePattern":"Unable to compile graph shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/src/layout/dock/graph/webglRenderer.ts","lineNumber":497,"sourceCode":"        gl.deleteShader(vertex);\n        gl.deleteShader(fragment);\n        if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n            const message = gl.getProgramInfoLog(program) || \"Unable to link graph shader\";\n            gl.deleteProgram(program);\n            throw new Error(message);\n        }\n        return program;\n    }\n\n    private createShader(type: number, source: string) {\n        const gl = this.gl;\n        const shader = this.requireValue(gl.createShader(type));\n        gl.shaderSource(shader, source);\n        gl.compileShader(shader);\n        if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n            const message = gl.getShaderInfoLog(shader) || \"Unable to compile graph shader\";\n            gl.deleteShader(shader);\n            throw new Error(message);\n        }\n        return shader;\n    }\n\n    private getUniform(program: WebGLProgram, name: string) {\n        return this.requireValue(this.gl.getUniformLocation(program, name));\n    }\n\n    private requireValue<T>(value: T | null): T {\n        if (value === null) {\n            throw new Error(\"Unable to allocate graph rendering resource\");\n        }\n        return value;\n    }\n}\n","sourceCodeStart":479,"sourceCodeEnd":513,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/app/src/layout/dock/graph/webglRenderer.ts#L479-L513","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nif (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n    throw new Error(gl.getShaderInfoLog(shader) || 'Unable to compile graph shader');\n}\n// after\nif (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n    const log = gl.getShaderInfoLog(shader);\n    console.error('shader compile failed:', log, '\\nin source:\\n', source);\n    gl.deleteShader(shader);\n    throw new Error('Graph shader compile failed; see console for GLSL info log');\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return new WebGLRenderer(canvas); }\ncatch (e) {\n    if (/compile/i.test(e.message)) console.error('GLSL compile error:', e.message);\n    showGraphFallback();\n    return null;\n}","preventionTips":["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."],"tags":["webgl","glsl","graph","typescript"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}