{"record":{"id":"b73ca51743f69eaf","repo":"pbakaus/impeccable","slug":"shader-compile-failed-info","errorCode":null,"errorMessage":"shader compile failed: ${info}","messagePattern":"shader compile failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/live-browser.js","lineNumber":8511,"sourceCode":"    let r = 0, g = 0, b = 0, n = 0;\n    for (const [px, py] of pts) {\n      const cx = Math.max(0, Math.min(W - 1, Math.round(px)));\n      const cy = Math.max(0, Math.min(H - 1, Math.round(py)));\n      const d = ctx.getImageData(cx, cy, 1, 1).data;\n      if (d[3] === 0) continue; // outside the ancestor's paint\n      r += d[0]; g += d[1]; b += d[2]; n++;\n    }\n    return n ? [r / n / 255, g / n / 255, b / n / 255] : null;\n  }\n\n  function compileShader(gl, type, source) {\n    const sh = gl.createShader(type);\n    gl.shaderSource(sh, source);\n    gl.compileShader(sh);\n    if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) {\n      const info = gl.getShaderInfoLog(sh);\n      gl.deleteShader(sh);\n      throw new Error('shader compile failed: ' + info);\n    }\n    return sh;\n  }\n\n  function positionShaderOverlay() {\n    if (!shaderState) return;\n    const anchor = resolveBarAnchor();\n    if (!anchor) return;\n    const r = anchor.getBoundingClientRect();\n    Object.assign(shaderState.canvas.style, {\n      top: r.top + 'px', left: r.left + 'px',\n      width: r.width + 'px', height: r.height + 'px',\n    });\n  }\n\n  /** Drop a shader node no shaderState owns (an abandoned construction). */\n  function removeStrayShaderNode() {\n    const stray = uiGetById(PREFIX + '-shader');","sourceCodeStart":8493,"sourceCodeEnd":8529,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L8493-L8529","documentation":"compileShader throws this when a WebGL shader fails to compile: gl.getShaderParameter(sh, gl.COMPILE_STATUS) is false. It includes the driver's gl.getShaderInfoLog output so the offending GLSL line/syntax is identifiable, and deletes the failed shader before throwing.","triggerScenarios":"The shader source (e.g. the halftone SHADER_FS/vertex shader) contains GLSL that the GPU/driver rejects — syntax errors, unsupported GLSL version/extension, or uniform/varying mismatches on a specific machine's driver.","commonSituations":"Users on old or buggy GPU drivers rejecting otherwise-valid GLSL; headless or software renderers (SwiftShader limits); a code change introducing a GLSL typo or an ES 3.0 construct on an ES 1.0 context.","solutions":["Read the info log appended to the message — it names the GLSL line and error","Validate the shader source for GLSL ES compatibility (avoid ES 3.00 syntax on a WebGL1 context)","Test on another machine/browser to isolate driver-specific compile failures","Check that context creation requested the needed attributes (antialias, precision) and that precision qualifiers are declared"],"exampleFix":"// before\nconst info = gl.getShaderInfoLog(sh);\nthrow new Error('shader compile failed: ' + info);\n// after\nconst info = gl.getShaderInfoLog(sh);\nconsole.error('shader source:\\n' + source.split('\\n').map((l,i)=>(i+1)+': '+l).join('\\n'));\nthrow new Error('shader compile failed: ' + info);","handlingStrategy":"try-catch","validationCode":"// preflight: compile in a scratch context before committing the effect\nconst test = gl.createShader(gl.FRAGMENT_SHADER);\ngl.shaderSource(test, SHADER_FS); gl.compileShader(test);\nif (!gl.getShaderParameter(test, gl.COMPILE_STATUS)) console.warn(gl.getShaderInfoLog(test));","typeGuard":null,"tryCatchPattern":"try {\n  initShaderOverlay();\n} catch (err) {\n  if (err.message.startsWith('shader compile failed')) {\n    console.error(err.message); // includes the GLSL info log\n    showToast('GPU shader unsupported on this device; falling back to CSS.');\n  }\n}","preventionTips":["Read the info log — it points at the exact GLSL line and token","Keep GLSL ES 1.00-compatible unless the context is explicitly WebGL2","Test effects on low-end/software GL renderers before shipping","Declare precision qualifiers and avoid driver-fragile constructs (dynamic loops, non-constant indices)"],"tags":["webgl","glsl","shader","gpu"],"backgroundTag":"shader-compile-failed","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}