a-b-street/abstreet · critical · anyhow::Error
error compiling shader
Error message
error compiling shader: {} What it means
compile_shader in widgetry's glow backend wraps OpenGL shader compilation: it uploads the shader source, compiles it, and if the driver reports a compile failure it bails with the driver's info log. The message is a low-level rendering backend error surfacing a GLSL problem.
Solutions
- Read the info log appended to the error message and fix the GLSL syntax/feature it points to
- Update GPU drivers or run on hardware supporting the required OpenGL version
- Check the GLSL version header (#version) matches the context's supported version
- If the shader was recently changed, revert and re-apply the change carefully
Example fix
// before #version 410 core // after #version 150 core // match the driver's supported GLSL version
Defensive patterns
Strategy: try-catch
Validate before calling
if !gl.get_shader_compile_status(shader) {
eprintln!("shader log: {}", gl.get_shader_info_log(shader));
} Try / catch
match widgetry_app::run(settings) {
Ok(()) => {},
Err(e) if e.to_string().starts_with("error compiling shader") => {
eprintln!("GPU/driver rejected shader: {}\ntry updating drivers or another machine", e);
std::process::exit(1);
}
Err(e) => return Err(e),
} Prevention
- Verify the target machine's OpenGL/GPU driver supports the required GLSL version
- Avoid editing shipped shaders without testing on the lowest-spec supported machine
- Pin a supported GLSL #version header and keep shader code under review
- Test on software renderers/VMs early if deploying to constrained environments
When it happens
Trigger: Any widgetry program whose GLSL source fails to compile on the current GPU/driver, e.g. shader syntax errors, unsupported GLSL version directives, or features the driver rejects.
Common situations: Running on machines with old/limited GPU drivers, missing OpenGL version support (e.g. VMs or software renderers), recently modified shader code with a typo, driver-specific GLSL strictness.
Related errors
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/e58ee7cc43c787b0.
Report an issue: GitHub.
Appendix: source
Thrown at widgetry/src/backend_glow.rs:67
glow::ONE,
glow::ONE_MINUS_SRC_ALPHA,
glow::ONE_MINUS_DST_ALPHA,
glow::ONE,
);
Ok(program)
}
unsafe fn compile_shader(
gl: &glow::Context,
shader_type: u32,
shader_source: &str,
) -> anyhow::Result<glow::Shader> {
let shader = gl.create_shader(shader_type).map_err(|e| anyhow!(e))?;
gl.shader_source(shader, shader_source);
gl.compile_shader(shader);
if !gl.get_shader_compile_status(shader) {
bail!("error compiling shader: {}", gl.get_shader_info_log(shader));
}
Ok(shader)
}
// Represents one frame that's gonna be drawn
pub struct GfxCtxInnards<'a> {
gl: &'a glow::Context,
current_clip: Option<[i32; 4]>,
transform_location: <glow::Context as glow::HasContext>::UniformLocation,
window_location: <glow::Context as glow::HasContext>::UniformLocation,
}
impl<'a> GfxCtxInnards<'a> {
pub fn new(
gl: &'a glow::Context,
program: &'a <glow::Context as glow::HasContext>::Program,
) -> Self {View on GitHub (pinned to 0964f29315)