emilk/egui · critical
Shape::Callback passed to Tessellator
Error message
Shape::Callback passed to Tessellator
What it means
This panic fires when a `Shape::Callback` variant is handed to the `Tessellator`. Callback shapes are special: they are executed by the painter/render pipeline with direct access to the callback context, and cannot be converted into triangles by the tessellator. The library treats this as an unreachable internal state and panics deliberately.
Source
Thrown at crates/epaint/src/tessellator.rs:1470
Shape::Rect(rect_shape) => {
self.tessellate_rect(&rect_shape, out);
}
Shape::Text(text_shape) => {
if self.options.debug_paint_text_rects {
let rect = text_shape.galley.rect.translate(text_shape.pos.to_vec2());
self.tessellate_rect(
&RectShape::stroke(rect, 2.0, (0.5, Color32::GREEN), StrokeKind::Outside),
out,
);
}
self.tessellate_text(&text_shape, out);
}
Shape::QuadraticBezier(quadratic_shape) => {
self.tessellate_quadratic_bezier(&quadratic_shape, out);
}
Shape::CubicBezier(cubic_shape) => self.tessellate_cubic_bezier(&cubic_shape, out),
Shape::Callback(_) => {
panic!("Shape::Callback passed to Tessellator");
}
}
}
/// Tessellate a single [`CircleShape`] into a [`Mesh`].
///
/// * `shape`: the circle to tessellate.
/// * `out`: triangles are appended to this.
pub fn tessellate_circle(&mut self, shape: CircleShape, out: &mut Mesh) {
let CircleShape {
center,
radius,
mut fill,
stroke,
} = shape;
if radius <= 0.0 {
return;View on GitHub (pinned to 441971a776)
Solutions
- Filter out `Shape::Callback` before tessellating: iterate shapes and match `Shape::Callback(cb) => cb.call(ctx)` separately, tessellating only mesh/text shapes.
- If you need the callback's pixels, execute the callback first (giving it a Painter) and then tessellate the shapes it produces.
- Check whether your egui version moved callback handling into the renderer (e.g. `Renderer::paint` handles callbacks); update integration code to not tessellate raw shape lists containing callbacks.
Example fix
// before
for shape in shapes {
tessellator.tessellate_shape(shape, &mut out);
}
// after
for shape in shapes {
match &shape {
Shape::Callback(_) => { /* execute callback via renderer instead */ }
_ => tessellator.tessellate_shape(shape, &mut out),
}
} Defensive patterns
Strategy: type-guard
Validate before calling
// Rust: filter callback shapes before tessellation let tessellatable: Vec<&Shape> = shapes.iter().filter(|s| !matches!(s, Shape::Callback(_))).collect();
Type guard
fn is_tessellatable(shape: &Shape) -> bool {
!matches!(shape, Shape::Callback(_))
} Try / catch
// Rust: this is a panic, not a Result; guard at call site instead
if matches!(shape, Shape::Callback(_)) {
// route to renderer callback path, never to tessellator
} else {
tessellator.tessellate_shape(shape, &mut out);
} Prevention
- Never write a loop that tessellates every `Shape` without matching on the variant first.
- Route `Shape::Callback` to the renderer (which executes it), not the tessellator.
- When writing screenshot/export code, explicitly document how callbacks are skipped or executed.
When it happens
Trigger: Calling `tessellate_shape` (directly or via `tessellate_clipped_shape`) on a `Shape::Callback(...)`. This happens if callback shapes are not filtered out before tessellation, e.g. by custom rendering code that collects all shapes from a `Shape` list and tessellates them indiscriminately.
Common situations: Custom renderers or screenshot/texture dumping code that iterate `paint_output.shapes` and tessellate every shape, forgetting that callbacks are not tessellable. Also occurs when cloning/reordering shapes and accidentally routing a callback shape into a tessellation pass.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Failed to read {}: {}
- {err}
- Harness::ui_id is only available for harnesses built with a
- Unsupported value for UPDATE_SNAPSHOTS: {unknown:?}
- {err}
AI-assisted analysis of emilk/egui@441971a776 (2026-09-12).
Data as JSON: /api/errors/f99b6b25a19bae19.
Report an issue: GitHub.