GraphiteEditor/Graphite · error

Failed to draw arc

Error message

Failed to draw arc

What it means

The dowel pin overlay draws two filled sectors with arc() calls whose start/end angles are FRAC_PI_2 + angle .. PI + angle. wasm-bindgen types arc as Result<(), JsValue>, and this .expect("Failed to draw arc") turns any JS throw into a WASM abort. Spec-wise non-finite angles are ignored, not thrown, so the realistic throw is again a negative radius or a browser-specific error on an invalidated context.

Source

Thrown at editor/src/messages/portfolio/document/overlays/utility_types_web.rs:839

	pub fn dowel_pin(&mut self, position: DVec2, angle: f64, color: Option<&str>) {
		let (x, y) = self.snap_to_physical_pixel_center(position).into();
		let color = color.unwrap_or(COLOR_OVERLAY_YELLOW_DULL);

		self.start_dpi_aware_transform();

		// Draw the background circle with a white fill and blue outline
		self.render_context.begin_path();
		self.render_context.arc(x, y, DOWEL_PIN_RADIUS, 0., TAU).expect("Failed to draw the circle");
		self.render_context.set_fill_style_str(COLOR_OVERLAY_WHITE);
		self.render_context.fill();
		self.render_context.set_stroke_style_str(color);
		self.render_context.stroke();

		// Draw the two blue filled sectors
		self.render_context.begin_path();
		// Top-left sector
		self.render_context.move_to(x, y);
		self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle).expect("Failed to draw arc");
		self.render_context.close_path();
		// Bottom-right sector
		self.render_context.move_to(x, y);
		self.render_context.arc(x, y, DOWEL_PIN_RADIUS, PI + FRAC_PI_2 + angle, TAU + angle).expect("Failed to draw arc");
		self.render_context.close_path();
		self.render_context.set_fill_style_str(color);
		self.render_context.fill();

		self.end_dpi_aware_transform();
	}

	pub fn arc_sweep_angle(&mut self, offset_angle: f64, angle: f64, end_point_position: DVec2, bold_radius: f64, pivot: DVec2, text: &str, transform: DAffine2) {
		self.manipulator_handle(end_point_position, true, None);
		self.draw_arc_gizmo_angle(pivot, bold_radius, ARC_SWEEP_GIZMO_RADIUS, offset_angle, angle.to_radians());
		self.text(&text, COLOR_OVERLAY_BLUE, None, transform, 16., [Pivot::Middle, Pivot::Middle]);
	}

	/// Used by the Pen and Path tools to outline the path of the shape.

View on GitHub (pinned to c507b35645)

Solutions

  1. Assert angle and position are finite (angle.is_finite()) before drawing the dowel pin sectors
  2. Confirm DOWEL_PIN_RADIUS remains a positive constant after refactors
  3. Handle the Result instead of expecting, logging and skipping the sector draw on error

Example fix

// before
self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle).expect("Failed to draw arc");

// after
if let Err(e) = self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle) {
	log::error!("Failed to draw dowel pin sector: {e:?}");
}
Defensive patterns

Strategy: validation

Validate before calling

if !angle.is_finite() {
	log::error!("dowel_pin called with non-finite angle {angle}");
	return;
}

Try / catch

if let Err(js_err) = self.render_context.arc(x, y, DOWEL_PIN_RADIUS, FRAC_PI_2 + angle, PI + angle) {
	log::error!("dowel pin sector arc failed: {js_err:?}");
}

Prevention

When it happens

Trigger: Calling dowel_pin with an angle or position that degenerates (NaN angle does not throw per spec but signals upstream math bugs), or arc throwing on a negative/invalid DOWEL_PIN_RADIUS or an invalidated 2D context.

Common situations: Passing an uninitialized (NaN) angle from transform decompositions into overlay drawing; refactoring DOWEL_PIN_RADIUS; browsers that throw rather than ignore degenerate arc arguments.

Related errors


AI-assisted analysis of GraphiteEditor/Graphite@c507b35645 (2026-08-16). Data as JSON: /api/errors/1dadf0ab8daa24c9. Report an issue: GitHub.