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 <noreply@anthropic.com>
This commit is contained in:
bherbruck
2026-10-27 15:16:48 +00:00
committed by GitHub
parent 02981d6bcf
commit 35913ced46
+11 -2
View File
@@ -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"] {