From 35913ced4686395536bdb3e269e78f3d018e4613 Mon Sep 17 00:00:00 2001 From: bherbruck Date: Tue, 27 Oct 2026 15:16:48 +0000 Subject: [PATCH] Fix flaky dielectric_preflight_and_start test: render a view that does not hit a box edge (#7722) The default view sends the single pixel's ray through a box edge, which the raytracer rejects as an ambiguous interface normal. The job then ended Failed whenever the render thread got ahead of render.cancel (about 7% of runs under load), and the test only accepted Cancelled or Completed. Render off-axis so the outcome no longer depends on that race, and print the phase and error if it ever fails again. Co-authored-by: Claude Opus 5.5 --- crates/engine/src/cmd/render/job_tests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/render/job_tests.rs b/crates/engine/src/cmd/render/job_tests.rs index 4b8391605..b534d3438 100644 --- a/crates/engine/src/cmd/render/job_tests.rs +++ b/crates/engine/src/cmd/render/job_tests.rs @@ -1044,9 +1044,13 @@ fn dielectric_preflight_and_start_resolve_refraction_without_broadening_boundari let mut s = Session::default(); s.set_render_job_host(Some(host.clone())).unwrap(); s.execute("solid.box", &json!({"length":20,"width":20,"height":2,"body_name":"Glass"})).unwrap(); + // The default view sends the single pixel's ray exactly through a box edge, which the optics reject + // as an ambiguous interface normal. Whether the job then ends Failed or Cancelled would depend on + // whether the cancel below beats the render thread, so view the glass off-axis. + let camera = solidcraft_render::Camera { yaw: 0.3, pitch: 0.4, ..Default::default() }; let document = s.doc.clone(); let before = (s.revision, s.evaluations, s.is_dirty(), s.undo.len(), s.redo.len()); - let params = json!({"integrator":"raytrace","settings":{"width":1,"height":1},"raytrace":{"dielectrics":[{ + let params = json!({"integrator":"raytrace","settings":{"width":1,"height":1,"camera":camera},"raytrace":{"dielectrics":[{ "body_index":0,"body_name":"Glass","boundary":"closed_box","ior":1.5,"absorption_per_mm":[0,0,0],"thickness_mm":0 }]}}); for command in ["render.preflight", "render.start"] { @@ -1065,7 +1069,12 @@ fn dielectric_preflight_and_start_resolve_refraction_without_broadening_boundari let handle = s.render_job_handle(id).unwrap(); s.execute("render.cancel", &json!({"job":id})).unwrap(); let status = handle.wait_timeout(std::time::Duration::from_secs(10)).unwrap(); - assert!(matches!(status.progress.phase, solidcraft_render::job::Phase::Cancelled | solidcraft_render::job::Phase::Completed)); + assert!( + matches!(status.progress.phase, solidcraft_render::job::Phase::Cancelled | solidcraft_render::job::Phase::Completed), + "phase {:?}, error {:?}", + status.progress.phase, + status.error + ); } } for boundary in ["closed_mesh", "thin_sheet"] {