From b94c65b005c1f936b7919c2ded2bfd258cd24f7d Mon Sep 17 00:00:00 2001 From: selune <35337584+0xlillith@users.noreply.github.com> Date: Fri, 30 Oct 2026 09:36:20 +0100 Subject: [PATCH] Archive unrun native Interactive placement and waiting-canvas proposals --- .../2026-10-30/native-followups/README.md | 17 ++ .../native-followups/placement.patch | 255 ++++++++++++++++++ .../native-followups/waiting-canvas.patch | 233 ++++++++++++++++ 3 files changed, 505 insertions(+) create mode 100644 proposals/render/2026-10-30/native-followups/README.md create mode 100644 proposals/render/2026-10-30/native-followups/placement.patch create mode 100644 proposals/render/2026-10-30/native-followups/waiting-canvas.patch diff --git a/proposals/render/2026-10-30/native-followups/README.md b/proposals/render/2026-10-30/native-followups/README.md new file mode 100644 index 000000000..016e676ad --- /dev/null +++ b/proposals/render/2026-10-30/native-followups/README.md @@ -0,0 +1,17 @@ +# Native Interactive preview follow-ups, 30 October 2026 + +These are separate proposed patches against the frozen local M2/M3 candidate based on production draft head a077906234972dbbf11e80c54893f85ece97c8b7. They are archived for review and continuity, not applied to production or qualified by the earlier candidate's tests. Both are unformatted, uncompiled and unrun. + +## Placement + +Native mouse-and-keyboard testing found the provisional preview status/actions overlapping the selected-body toolbar. placement.patch moves only our card into measured current-frame free space. A minimal composition-order hook draws the existing selection bar before measuring it; its implementation, controls and gizmos remain unchanged. Two original tests cover wide/narrow placement and real selection/Pause/Off hit targets. Extremely obstructed canvases and the shared helper's 16-obstacle bound remain explicit limitations. Coordination with the panel owner and native after-validation remain required. + +## Waiting canvas + +During supported edits the current candidate drops the invalidated ray-traced image, displays Model Preview with different lighting, then replaces it with the new provisional image. waiting-canvas.patch preserves all image identity/invalidation guards and suppresses that fallback only while an active current CPU Interactive context awaits its pixels. It does not claim an image was painted and does not reuse stale pixels. The tradeoff is a temporarily empty model canvas during updating; continuous edits may prolong that wait. Four original tests cover actual show routing, accepted edits/new captures, paused out-of-date pixels, and camera/document/late-callback isolation. + +## Integration and validation + +Apply placement first, then re-pin and transplant the waiting hunks and append its tests. Do not overwrite whole files or apply the overlapping test append blindly. Preserve both individual patches and all original assertions. An independent review and a combined private candidate are pending. The shared checkout remains frozen during native acceptance. One builder will validate the combined exact source after the app closes and its runtime is drained; native before/after checks, the repository gate and publication readiness are still pending. No physical GPU acceptance or full CI result is claimed. + +Related: #6201 and draft #8938. diff --git a/proposals/render/2026-10-30/native-followups/placement.patch b/proposals/render/2026-10-30/native-followups/placement.patch new file mode 100644 index 000000000..49e8e91ae --- /dev/null +++ b/proposals/render/2026-10-30/native-followups/placement.patch @@ -0,0 +1,255 @@ +--- a/crates/ui-egui/src/render_workspace_interactive.rs ++++ b/crates/ui-egui/src/render_workspace_interactive.rs +@@ -464,25 +464,58 @@ + true + } + +-pub(crate) fn overlay(app: &mut SolveApp, ui: &egui::Ui, free: egui::Rect) { +- let width = (free.width() - Tokens::get().space_8 * 2.0).min(Tokens::get().form_card_width); +- if width < Tokens::get().control_height { +- return; +- } +- let card = ui_kit::Container::navigation_card( +- ui.ctx(), +- egui::Id::new("sc_render_interactive_controls"), +- free.center_top(), +- egui::Align2::CENTER_TOP, +- |ui| { +- ui.set_width(width); +- ui.set_max_width(width); +- ui.set_clip_rect(ui.clip_rect().intersect(free)); +- controls(app, ui); +- }, +- ); +- crate::shell::register_panel(app, "render:interactive-card", Some(card.response.rect.intersect(free)), None); +- crate::scenario::publish_rect("render:interactive-card", card.response.rect.intersect(free)); ++/// Place only our card in current-frame space; never move another workspace surface. ++pub(super) fn overlay_bounds(app: &SolveApp, free: egui::Rect) -> egui::Rect { ++ if !free.is_finite() || !free.is_positive() { ++ return egui::Rect::NOTHING; ++ } ++ let gap = Tokens::get().space_8; ++ let available = crate::shell::workspace_content(app, free).shrink(gap); ++ let mut obstacles = Vec::new(); ++ for (id, (rect, edge)) in &app.shell.workspace_panels { ++ if *id != "render:interactive-card" && edge.is_none() { ++ obstacles.push(rect.expand(gap)); ++ } ++ } ++ if let Some(layout) = &app.viewport.layout { ++ obstacles.extend([layout.axis_view, layout.navigation, layout.confirm].map(|rect| rect.expand(gap))); ++ } ++ crate::viewport_layout::free_rect(available, &obstacles) ++} ++ ++pub(crate) fn overlay(app: &mut SolveApp, ui: &egui::Ui, free: egui::Rect) { ++ let bounds = overlay_bounds(app, free); ++ let t = Tokens::get(); ++ // Match navigation_card's real chrome, including theme-dependent borders. ++ let chrome = ui_kit::Container::new(ui.ctx(), ui_kit::Surface::Navigation) ++ .frame(ui.ctx(), t.overlay, crate::frame::Side::Left) ++ .inner_margin(t.space_4) ++ .total_margin() ++ .sum(); ++ let width = (bounds.width() - chrome.x).min(t.form_card_width); ++ let height = bounds.height() - chrome.y; ++ if !bounds.is_finite() || width < t.control_height || height < t.control_height { ++ return; ++ } ++ let card = ui_kit::Container::navigation_card( ++ ui.ctx(), ++ egui::Id::new("sc_render_interactive_controls"), ++ bounds.left_top(), ++ egui::Align2::LEFT_TOP, ++ |ui| { ++ ui.set_width(width); ++ ui.set_max_width(width); ++ ui.set_clip_rect(ui.clip_rect().intersect(bounds)); ++ egui::ScrollArea::vertical() ++ .id_salt("sc_render_interactive_controls_scroll") ++ .min_scrolled_height(0.0) ++ .max_height(height) ++ .auto_shrink([false, true]) ++ .show(ui, |ui| controls(app, ui)); ++ }, ++ ); ++ crate::shell::register_panel(app, "render:interactive-card", Some(card.response.rect.intersect(bounds)), None); ++ crate::scenario::publish_rect("render:interactive-card", card.response.rect.intersect(bounds)); + } + pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) { + let state = &app.render_workspace.interactive; +--- a/crates/ui-egui/src/render_ui/mod.rs ++++ b/crates/ui-egui/src/render_ui/mod.rs +@@ -185,19 +185,19 @@ + if !free.is_positive() { + return; + } +- crate::shell::register_panel(app, "render:interactive-card", None, None); +- if crate::render_workspace::job_busy(app) { +- let pill = Container::navigation_card(ui.ctx(), egui::Id::new("sc_render_progress"), free.center_top(), egui::Align2::CENTER_TOP, |ui| { +- crate::render_workspace::progress_pill(app, ui); +- }); +- crate::shell::register_panel(app, "render:progress-pill", Some(pill.response.rect), None); +- crate::scenario::publish_rect("render:progress-pill", pill.response.rect); +- } else { +- crate::shell::register_panel(app, "render:progress-pill", None, None); +- crate::render_workspace::interactive::overlay(app, ui, free); +- } +- crate::render_workspace::environment_overlay(app, ui, viewport); +- crate::render_workspace::assign::selection_bar(app, ui, free); ++ crate::render_workspace::assign::selection_bar(app, ui, free); ++ crate::shell::register_panel(app, "render:interactive-card", None, None); ++ if crate::render_workspace::job_busy(app) { ++ let pill = Container::navigation_card(ui.ctx(), egui::Id::new("sc_render_progress"), free.center_top(), egui::Align2::CENTER_TOP, |ui| { ++ crate::render_workspace::progress_pill(app, ui); ++ }); ++ crate::shell::register_panel(app, "render:progress-pill", Some(pill.response.rect), None); ++ crate::scenario::publish_rect("render:progress-pill", pill.response.rect); ++ } else { ++ crate::shell::register_panel(app, "render:progress-pill", None, None); ++ crate::render_workspace::interactive::overlay(app, ui, free); ++ } ++ crate::render_workspace::environment_overlay(app, ui, viewport); + crate::render_workspace::assign::replacement_dialog(app, ui.ctx()); + crate::navigation_bar_view::show(app, ui, viewport); + if !focused(app) { +--- a/crates/ui-egui/src/render_workspace_tests.rs ++++ b/crates/ui-egui/src/render_workspace_tests.rs +@@ -7451,3 +7451,137 @@ + output.textures_delta.clear(); + h.app.run("render.interactive", json!({"action":"off"})).unwrap(); + } ++ ++#[test] ++fn interactive_card_bounds_avoid_current_selection_docks_and_navigation_at_wide_and_narrow_sizes() { ++ for (width, height) in [(1600.0, 1000.0), (760.0, 700.0)] { ++ let mut h = Harness::new(); ++ h.app.ui.tab = "RENDER".into(); ++ h.app.shell.workspace_panels.clear(); ++ let viewport = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(width, height)); ++ let content = egui::Rect::from_min_max(egui::pos2(0.0, 132.0), egui::pos2(width, height - 56.0)); ++ let left = egui::Rect::from_min_max(egui::pos2(8.0, 140.0), egui::pos2(274.0, height - 64.0)); ++ let right = egui::Rect::from_min_max(egui::pos2(width - 313.0, 140.0), egui::pos2(width - 8.0, height - 64.0)); ++ crate::shell::register_panel(&mut h.app, "render:browser", Some(left), Some(crate::ui_kit::Edge::Left)); ++ crate::shell::register_panel(&mut h.app, "render:inspector", Some(right), Some(crate::ui_kit::Edge::Right)); ++ let centre = (left.right() + right.left()) / 2.0; ++ let navigation = egui::Rect::from_center_size(egui::pos2(centre, content.bottom() - 28.0), egui::vec2(120.0, 40.0)); ++ let axis = egui::Rect::from_min_size(egui::pos2(right.left() - 110.0, content.top()), egui::vec2(110.0, 110.0)); ++ h.app.viewport.layout = Some(crate::viewport_layout::Layout { ++ viewport, ++ drawable: content, ++ content, ++ axis_view: axis, ++ navigation, ++ confirm: egui::Rect::NOTHING, ++ }); ++ // A new measured selection replaces the old one in this very frame. ++ // Both positions cut across the old top-centre status/action region. ++ for y in [content.top() + 90.0, content.top() + 180.0] { ++ let selection = egui::Rect::from_center_size(egui::pos2(centre, y), egui::vec2(180.0, 34.0)); ++ crate::shell::register_panel(&mut h.app, "render:selection", Some(selection), None); ++ let available = interactive::overlay_bounds(&h.app, content); ++ assert!(available.is_positive(), "{width}: no space for the Interactive card"); ++ assert!(content.contains_rect(available), "{width}: {available:?} outside {content:?}"); ++ for occupied in [selection, left, right, navigation, axis] { ++ assert!(!available.intersect(occupied).is_positive(), "{width}: {available:?} overlaps {occupied:?}"); ++ } ++ assert!(available.width() >= Tokens::get().control_height + Tokens::get().space_8); ++ } ++ assert!(!interactive::overlay_bounds(&h.app, egui::Rect::NOTHING).is_positive()); ++ assert_eq!(h.app.shell.workspace_panels["render:browser"].0, left); ++ assert_eq!(h.app.shell.workspace_panels["render:inspector"].0, right); ++ } ++} ++ ++#[cfg(not(target_arch = "wasm32"))] ++#[test] ++fn interactive_overlay_keeps_real_selection_actions_and_pause_off_targets_accessible_without_dispatch() { ++ fn overlay_frame(h: &mut Harness, size: egui::Vec2, events: Vec) { ++ let mut output = h.ctx.run_ui( ++ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), events, ..Default::default() }, ++ |ui| { ++ // The shell clears Render reservations at the start of a real frame. ++ // Keep the already measured docks but never leave a previous selection ++ // rectangle that could make the moved-call regression pass by accident. ++ h.app.shell.workspace_panels.remove("render:selection"); ++ crate::render_ui::overlays(&mut h.app, ui); ++ }, ++ ); ++ output.textures_delta.clear(); ++ } ++ for size in [egui::vec2(1600.0, 1000.0), egui::vec2(760.0, 700.0)] { ++ let mut h = interactive_ui_fixture(); ++ if !interactive_test_cpu_branch(&mut h, "interactive_overlay_selection_controls") { ++ return; ++ } ++ h.call("ui.resize", json!({"width":size.x as u32,"height":size.y as u32})); ++ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Blue"})).unwrap(); ++ h.app.run("select.filter", json!({"mode":"body"})).unwrap(); ++ h.app.run("select.set", json!({"items":[solidcraft_engine::Sel::Body {name:"Subject".into()}]})).unwrap(); ++ h.frames(4); ++ for _ in 0..3 { ++ overlay_frame(&mut h, size, vec![]); ++ } ++ let selection_before = crate::scenario::rect_of("render:selection").unwrap(); ++ let actions_before: Vec<_> = (0..4).map(|index| crate::scenario::rect_of(&format!("selection:action:{index}")).unwrap()).collect(); ++ let document = h.app.session.doc.clone(); ++ let history = (h.app.session.revision, h.app.session.undo.len(), h.app.session.redo.len()); ++ let camera = h.app.cam; ++ let docks = h.app.shell.workspace_panels.clone(); ++ h.app.render_workspace.view.method = ImageMethod::CpuRaytrace; ++ h.app.run("render.interactive", json!({"action":"on"})).unwrap(); ++ // Paint the production overlays, but never tick or run a Snapshot worker. ++ for _ in 0..3 { ++ overlay_frame(&mut h, size, vec![]); ++ } ++ let card = crate::scenario::rect_of("render:interactive-card").unwrap(); ++ let selection = crate::scenario::rect_of("render:selection").unwrap(); ++ assert_eq!(selection, selection_before, "our card must not move the author's toolbar"); ++ assert!(!card.intersect(selection).is_positive()); ++ let content = crate::render_ui::canvas(&h.app, h.app.viewport.rect.unwrap()); ++ assert!(content.contains_rect(card), "{size:?}: {card:?} outside {content:?}"); ++ for (index, before) in actions_before.iter().enumerate() { ++ let action = crate::scenario::rect_of(&format!("selection:action:{index}")).unwrap(); ++ assert_eq!(&action, before); ++ assert!(selection.contains_rect(action)); ++ assert!(!card.intersect(action).is_positive(), "author action {index} is occluded"); ++ } ++ for action in ["pause", "off"] { ++ let target = crate::scenario::rect_of(&format!("render:interactive:{action}")).unwrap(); ++ assert!(card.contains_rect(target), "{size:?}: {action} clipped outside {card:?}: {target:?}"); ++ assert!(!selection.intersect(target).is_positive()); ++ } ++ for action in ["pause", "off"] { ++ let at = crate::scenario::rect_of(&format!("render:interactive:{action}")).unwrap().center(); ++ for pressed in [true, false] { ++ overlay_frame( ++ &mut h, ++ size, ++ vec![ ++ egui::Event::PointerMoved(at), ++ egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }, ++ ], ++ ); ++ } ++ overlay_frame(&mut h, size, vec![]); ++ assert_eq!(interactive::inspect(&h.app)["paused"], action == "pause"); ++ assert_eq!(interactive::inspect(&h.app)["enabled"], action != "off"); ++ assert!(!h.app.render_workspace.interactive.pending()); ++ } ++ assert_eq!(h.app.cam, camera); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!((h.app.session.revision, h.app.session.undo.len(), h.app.session.redo.len()), history); ++ assert!(h.app.render_workspace.view.job.is_none() && h.app.render_workspace.view.completed.is_none()); ++ for id in ["render:browser", "render:inspector", "render:appearances", "render:shots_strip"] { ++ let current = h.app.shell.workspace_panels.get(id).map(|(rect, edge)| (*rect, edge.as_ref().map(std::mem::discriminant))); ++ let before = docks.get(id).map(|(rect, edge)| (*rect, edge.as_ref().map(std::mem::discriminant))); ++ assert_eq!(current, before, "{id}"); ++ } ++ // With Interactive Off, the author's real hit target still dispatches. ++ let favorite_count = h.app.preferences.render_library_favorites.len(); ++ h.step(&json!({"click":{"handle":"selection:action:2"}})).unwrap(); ++ assert_eq!(h.app.preferences.render_library_favorites.len(), favorite_count + 1); ++ assert_eq!(crate::scenario::rect_of("render:selection").unwrap(), selection_before); ++ } ++} diff --git a/proposals/render/2026-10-30/native-followups/waiting-canvas.patch b/proposals/render/2026-10-30/native-followups/waiting-canvas.patch new file mode 100644 index 000000000..cf189f1ee --- /dev/null +++ b/proposals/render/2026-10-30/native-followups/waiting-canvas.patch @@ -0,0 +1,233 @@ +diff --git a/crates/ui-egui/src/render_workspace_interactive.rs b/crates/ui-egui/src/render_workspace_interactive.rs +--- a/crates/ui-egui/src/render_workspace_interactive.rs ++++ b/crates/ui-egui/src/render_workspace_interactive.rs +@@ -443,6 +443,21 @@ + refresh(app, ctx, false); + } + ++/// Reserve the canvas while an active CPU preview awaits its current pixels. ++/// This never turns a waiting state into a painted image or retains old pixels. ++pub(super) fn awaiting_current_frame(app: &SolveApp) -> bool { ++ let state = &app.render_workspace.interactive; ++ super::active(app) ++ && app.render_workspace.view.method == ImageMethod::CpuRaytrace ++ && !app.render_workspace.view.result ++ && state.context.as_ref().is_some_and(|context| context.is_current(&app.session)) ++ && !state.user_paused ++ && !state.final_active ++ && state.error.is_none() ++ && matches!(state.phase, Phase::Updating | Phase::Refining) ++ && state.frame.is_none() ++} ++ + pub(super) fn paint(app: &SolveApp, ui: &egui::Ui, rect: egui::Rect) -> bool { + let state = &app.render_workspace.interactive; + if state.context.is_none() || state.final_active || state.error.is_some() { +diff --git a/crates/ui-egui/src/render_workspace.rs b/crates/ui-egui/src/render_workspace.rs +--- a/crates/ui-egui/src/render_workspace.rs ++++ b/crates/ui-egui/src/render_workspace.rs +@@ -2005,7 +2005,7 @@ + ui.painter().rect_filled(viewport, 0.0, Color32::from_rgb(bg[0], bg[1], bg[2])); + // Reobserve after the existing shared navigation path, before any pixel paint. + interactive::before_paint(app, ui.ctx()); +- if interactive::paint(app, ui, rect) { ++ if interactive::paint(app, ui, rect) || interactive::awaiting_current_frame(app) { + shot::overlay(app, ui, viewport); + crate::viewport::axis_view(app, ui, viewport); + crate::navigation_bar_view::show(app, ui, viewport); +diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rs +--- a/crates/ui-egui/src/render_workspace_tests.rs ++++ b/crates/ui-egui/src/render_workspace_tests.rs +@@ -7451,3 +7451,192 @@ + output.textures_delta.clear(); + h.app.run("render.interactive", json!({"action":"off"})).unwrap(); + } ++ ++#[cfg(not(target_arch = "wasm32"))] ++fn interactive_waiting_show_text(h: &mut Harness, time: f64) -> String { ++ let mut output = h.ctx.run_ui( ++ egui::RawInput { ++ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 900.0))), ++ time: Some(time), ++ ..Default::default() ++ }, ++ |ui| show(&mut h.app, ui), ++ ); ++ let text = crate::test_support::text_shapes(&output).map(|shape| shape.galley.job.text.clone()).collect::>().join("\n"); ++ output.textures_delta.clear(); ++ text ++} ++ ++#[cfg(not(target_arch = "wasm32"))] ++#[test] ++fn interactive_waiting_canvas_uses_real_show_and_keeps_off_pause_error_and_result_routes() { ++ let mut h = interactive_ui_fixture(); ++ if !interactive_test_cpu_branch(&mut h, "interactive_waiting_canvas_uses_real_show_and_keeps_off_pause_error_and_result_routes") { ++ return; ++ } ++ assert!(h.app.viewport.gpu.is_none(), "the fallback refusal is the real no-GPU positive control"); ++ let epoch = interactive::test_clock(&h.app).as_secs_f64(); ++ let fallback = h.app.tr("render.error_gpu_preview").to_string(); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ assert!(interactive_waiting_show_text(&mut h, epoch + 0.01).contains(&fallback)); ++ ++ h.app.run("render.interactive", json!({"action":"on"})).unwrap(); ++ let waiting = interactive_waiting_show_text(&mut h, epoch + 0.02); ++ assert_eq!(interactive::inspect(&h.app)["phase"], "Updating"); ++ assert!(interactive::awaiting_current_frame(&h.app)); ++ assert!(!waiting.contains(&fallback), "real show must not enter the model-preview refusal while waiting"); ++ assert!(interactive::test_cache(&h.app).is_none()); ++ assert!(!h.app.render_workspace.interactive.pending(), "show/before_paint must not dispatch"); ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.025, false, true); ++ assert!(!painted, "reserving the canvas does not claim an image was painted"); ++ output.textures_delta.clear(); ++ ++ h.app.render_workspace.view.result = true; ++ assert!(!interactive::awaiting_current_frame(&h.app), "the result view keeps priority"); ++ h.app.render_workspace.view.result = false; ++ h.app.render_workspace.view.method = ImageMethod::Raster; ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ h.app.render_workspace.view.method = ImageMethod::CpuRaytrace; ++ h.app.ui.tab = "MODEL".into(); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ h.app.ui.tab = "RENDER".into(); ++ ++ h.app.run("render.interactive", json!({"action":"pause"})).unwrap(); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ assert!(interactive_waiting_show_text(&mut h, epoch + 0.03).contains(&fallback), "pause before any image keeps its existing fallback"); ++ h.app.run("render.interactive", json!({"action":"resume"})).unwrap(); ++ assert!(!interactive_waiting_show_text(&mut h, epoch + 0.04).contains(&fallback)); ++ h.app.render_workspace.view.cpu.environment = cpu::Environment::Hdr; ++ h.app.render_workspace.view.cpu.hdr = hdr::Input::FilePending { path: h.dir.join("not-inspected.hdr").to_string_lossy().into_owned() }; ++ let error = interactive_waiting_show_text(&mut h, epoch + 0.05); ++ assert_eq!(interactive::inspect(&h.app)["phase"], "Error"); ++ assert!(!interactive::inspect(&h.app)["error"].is_null()); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ assert!(error.contains(&fallback), "an input error keeps the existing model-preview route"); ++ assert!(!h.app.render_workspace.interactive.pending()); ++ h.app.run("render.interactive", json!({"action":"off"})).unwrap(); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ assert!(interactive_waiting_show_text(&mut h, epoch + 0.06).contains(&fallback)); ++} ++ ++#[cfg(not(target_arch = "wasm32"))] ++#[test] ++fn interactive_waiting_canvas_after_supported_edit_drops_old_pixels_and_new_capture_still_publishes() { ++ let mut h = interactive_ui_fixture(); ++ if !interactive_test_cpu_branch( ++ &mut h, ++ "interactive_waiting_canvas_after_supported_edit_drops_old_pixels_and_new_capture_still_publishes", ++ ) { ++ return; ++ } ++ let epoch = interactive::test_clock(&h.app).as_secs_f64(); ++ h.app.render_workspace.view.raytrace.shadows = true; ++ h.app.run("render.interactive", json!({"action":"on"})).unwrap(); ++ let old = interactive_recovery_require_success(&mut h, epoch + 0.201, epoch + 0.3); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ let visual = interactive::inspect(&h.app)["visual_revision"].as_u64().unwrap(); ++ let document = h.app.session.doc.clone(); ++ ++ h.app.render_workspace.view.raytrace.shadows = false; ++ let text = interactive_waiting_show_text(&mut h, epoch + 0.4); ++ assert!(interactive::inspect(&h.app)["visual_revision"].as_u64().unwrap() > visual); ++ assert!(interactive::test_cache(&h.app).is_none(), "the previously accepted image must be dropped"); ++ assert!(interactive::awaiting_current_frame(&h.app)); ++ assert!(!text.contains(h.app.tr("render.error_gpu_preview"))); ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.41, false, true); ++ assert!(!painted, "old pixels cannot become current while the new request waits"); ++ output.textures_delta.clear(); ++ ++ let new = interactive_recovery_require_success(&mut h, epoch + 0.901, epoch + 1.0); ++ assert_ne!(new, old); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ let job = interactive::test_current(&h.app).unwrap().unwrap(); ++ assert_eq!(job.id(), new); ++ assert!(!job.status().unwrap().request.raytrace.as_ref().unwrap().shadows); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc), "presentation and runtime settings do not author CAD state"); ++ interactive_assert_final_export_isolation(&mut h, &job); ++ h.app.run("render.interactive", json!({"action":"off"})).unwrap(); ++} ++ ++#[cfg(not(target_arch = "wasm32"))] ++#[test] ++fn interactive_waiting_canvas_preserves_paused_out_of_date_pixels_and_resume_waits_without_fallback() { ++ let mut h = interactive_ui_fixture(); ++ if !interactive_test_cpu_branch( ++ &mut h, ++ "interactive_waiting_canvas_preserves_paused_out_of_date_pixels_and_resume_waits_without_fallback", ++ ) { ++ return; ++ } ++ let epoch = interactive::test_clock(&h.app).as_secs_f64(); ++ h.app.render_workspace.view.raytrace.shadows = true; ++ h.app.run("render.interactive", json!({"action":"on"})).unwrap(); ++ interactive_recovery_require_success(&mut h, epoch + 0.201, epoch + 0.3); ++ let (before, samples, complete, texture) = interactive::test_cache(&h.app).unwrap(); ++ h.app.run("render.interactive", json!({"action":"pause"})).unwrap(); ++ h.app.render_workspace.view.raytrace.shadows = false; ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.4, false, true); ++ assert!(painted, "explicit pause still permits the already displayed image"); ++ output.textures_delta.clear(); ++ assert_eq!(interactive::inspect(&h.app)["phase"], "Paused"); ++ assert_eq!(interactive::inspect(&h.app)["stale"], true); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ let (after, after_samples, after_complete, after_texture) = interactive::test_cache(&h.app).unwrap(); ++ assert_eq!((after.job, after.png_sha256), (before.job, before.png_sha256)); ++ assert_eq!((after_samples, after_complete, after_texture), (samples, complete, texture)); ++ ++ h.app.run("render.interactive", json!({"action":"resume"})).unwrap(); ++ let text = interactive_waiting_show_text(&mut h, epoch + 0.5); ++ assert_eq!(interactive::inspect(&h.app)["phase"], "Updating"); ++ assert!(interactive::test_cache(&h.app).is_none()); ++ assert!(interactive::awaiting_current_frame(&h.app)); ++ assert!(!text.contains(h.app.tr("render.error_gpu_preview"))); ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.51, false, true); ++ assert!(!painted); ++ output.textures_delta.clear(); ++ h.app.run("render.interactive", json!({"action":"off"})).unwrap(); ++} ++ ++#[cfg(not(target_arch = "wasm32"))] ++#[test] ++fn interactive_waiting_canvas_camera_late_callback_and_document_switch_never_adopt_old_pixels() { ++ let mut h = interactive_ui_fixture(); ++ if !interactive_test_cpu_branch(&mut h, "interactive_waiting_canvas_camera_late_callback_and_document_switch_never_adopt_old_pixels") { ++ return; ++ } ++ let epoch = interactive::test_clock(&h.app).as_secs_f64(); ++ h.app.run("render.interactive", json!({"action":"on"})).unwrap(); ++ interactive_clear_acceptance_frame(&mut h, epoch, true); ++ interactive_clear_acceptance_frame(&mut h, epoch + 0.201, true); ++ let held = interactive_hold_real_completed_callback(&mut h); ++ let visual = interactive::inspect(&h.app)["visual_revision"].as_u64().unwrap(); ++ h.app.cam.yaw += 0.2; ++ let text = interactive_waiting_show_text(&mut h, epoch + 0.3); ++ assert!(interactive::inspect(&h.app)["visual_revision"].as_u64().unwrap() > visual); ++ assert!(interactive::awaiting_current_frame(&h.app)); ++ assert!(!text.contains(h.app.tr("render.error_gpu_preview"))); ++ held.sender.send(held.reply).unwrap(); ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.4, false, true); ++ assert!(!painted); ++ output.textures_delta.clear(); ++ assert!(interactive::test_cache(&h.app).is_none()); ++ assert!(interactive::test_current(&h.app).unwrap().is_none()); ++ assert!(!h.app.render_workspace.interactive.pending()); ++ assert!(interactive::awaiting_current_frame(&h.app)); ++ interactive_assert_final_export_isolation(&mut h, &held.job); ++ ++ let old_uid = h.app.session.uid; ++ crate::documents::open_tab(&mut h.app, Session::default()).unwrap(); ++ assert_ne!(h.app.session.uid, old_uid); ++ assert!(!interactive::awaiting_current_frame(&h.app), "a foreign context cannot reserve the canvas even before refresh"); ++ h.app.ui.tab = "RENDER".into(); ++ interactive_clear_acceptance_frame(&mut h, epoch + 0.5, false); ++ assert!(!interactive::awaiting_current_frame(&h.app)); ++ assert!(interactive::test_cache(&h.app).is_none()); ++ let (mut output, painted) = interactive_acceptance_frame(&mut h, epoch + 0.6, false, true); ++ assert!(!painted, "neither the old image nor its waiting presentation belongs to another document"); ++ output.textures_delta.clear(); ++ assert_eq!(interactive::inspect(&h.app)["enabled"], false); ++ assert!(h.app.render_workspace.view.job.is_none() && h.app.render_workspace.view.completed.is_none()); ++} ++