test: cover intrinsic layout retargeting and idle task publication order
Verify Tessera GUI / verify (push) Failing after 8m37s
Verify Tessera GUI / verify (push) Failing after 8m37s
This commit is contained in:
+1
-1
@@ -163,7 +163,7 @@ UiBridge::begin_layout_frame/resume_layout_frame now expose PendingLayout around
|
||||
ReplSession now owns a resumable RefreshWork containing window traversal, pending bridge layout, unpublished per-window documents and the cumulative refresh work budget. poll_refresh advances one refresh stage or VM quantum; only a complete stable pass replaces the session's full document map. Synchronous callers drain the same state machine. Failure stops the domain, releases any pending bridge work and preserves the externally published picture. refreshYields counts cooperative refresh returns, not wall-clock time. Only still-pending Mount preparation is rolled back; completed callbacks remain committed.
|
||||
|
||||
|
||||
Viewport refresh now advances through ReplSession's saved refresh state on worker idle turns. A turn advances one traversal stage or a 256-instruction layout quantum; a pending job shortens the next worker wait to 1 ms. Tasks/window commands and document publication wait for complete refresh. ui.stats().refreshYields reports cooperative idle returns. Mutating requests first drain the existing job, so they cannot run inside its read-only scope. Mutating requests are serialized; newer viewport targets coalesce by cancelling unpublished layout. Initial loads, explicit REPL/event refresh and task callbacks still drain synchronously; native Rust measurement/paint calls remain atomic.
|
||||
Viewport refresh now advances through ReplSession's saved refresh state on worker idle turns. A turn advances one traversal stage or a 256-instruction layout quantum; a pending job shortens the next worker wait to 1 ms. Tasks/window commands and document publication wait for complete refresh. ui.stats().refreshYields reports cooperative idle returns. Mutating requests first drain the existing job, so they cannot run inside its read-only scope. Mutating requests are serialized; newer viewport targets coalesce by cancelling unpublished layout. Initial loads and explicit REPL/event refresh still drain synchronously. Idle tasks deliver at most one callback per turn and park subsequent layout; callbacks and individual native nodes remain atomic. Large intrinsic trees use the sliced driver; small intrinsic trees keep the fast path.
|
||||
|
||||
|
||||
Runtime mutation entry points reject direct calls while refresh work is pending, before executing source or changing metadata; task polling defers. The API worker drains the saved refresh before accepting those mutations, keeping the runtime usable. Incremental refresh keeps the prior complete document map until a stable pass, including across window traversal boundaries where no VM read-only frame is currently active.
|
||||
|
||||
+1
-1
@@ -1174,7 +1174,7 @@ source_layout::start now returns either Complete(Draft) or Pending(Work). The ho
|
||||
UiBridge::begin_layout_frame/resume_layout_frame now expose PendingLayout around the source job. This bridge-level continuation also owns its target window, page snapshot, tab projection, viewport restoration and retained lifecycle hook root. Only the Complete branch projects scroll/focus, captures dependency versions, merges derived caches, commits Mount geometry and runs deferred hooks. Resume restores the saved window context, and failure releases hook roots. ReplSession uses this protocol through its saved refresh state. Viewport refresh supports cross-worker-turn scheduling and prepared-Mount rollback; callers must not drop a pending bridge layout as a substitute for cancellation.
|
||||
|
||||
|
||||
Viewport refresh now advances through ReplSession's saved refresh state on worker idle turns. A turn advances one traversal stage or a 256-instruction layout quantum; a pending job shortens the next worker wait to 1 ms. Tasks/window commands and document publication wait for complete refresh. ui.stats().refreshYields reports cooperative idle returns. Mutating requests first drain the existing job, so they cannot run inside its read-only scope. Mutating requests are serialized; newer viewport targets coalesce by cancelling unpublished layout. Initial loads, explicit REPL/event refresh and task callback execution remains atomic; its idle-triggered layout yields across worker turns; native Rust measurement/paint calls remain atomic.
|
||||
Viewport refresh now advances through ReplSession's saved refresh state on worker idle turns. A turn advances one traversal stage or a 256-instruction layout quantum; a pending job shortens the next worker wait to 1 ms. Tasks/window commands and document publication wait for complete refresh. ui.stats().refreshYields reports cooperative idle returns. Mutating requests first drain the existing job, so they cannot run inside its read-only scope. Mutating requests are serialized; newer viewport targets coalesce by cancelling unpublished layout. Initial loads and explicit REPL/event refresh still drain synchronously. Idle tasks deliver at most one callback per turn and park subsequent layout; callbacks and individual native nodes remain atomic. Large intrinsic trees use the sliced driver; small intrinsic trees keep the fast path.
|
||||
|
||||
|
||||
Runtime mutation entry points reject direct calls while refresh work is pending, before executing source or changing metadata; task polling defers. The API worker drains the saved refresh before accepting those mutations, keeping the runtime usable. Incremental refresh keeps the prior complete document map until a stable pass, including across window traversal boundaries where no VM read-only frame is currently active.
|
||||
|
||||
@@ -4174,6 +4174,108 @@ page.render(block)
|
||||
assert_eq!(source_measure_stat(&mut session, "layoutCancels"), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_intrinsic_layout_yields_and_retargets_without_geometry_loss() {
|
||||
let children = std::iter::repeat_n("item", 80)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
let source = format!(
|
||||
"item = RectBlock(2,20)\nrow = Row(0,0,{children})\npage = Page()\npage.render(row)"
|
||||
);
|
||||
let (mut session, initial) = ReplSession::load(&source, "app.main", 273, 1).unwrap();
|
||||
let initial = initial.unwrap();
|
||||
let old_version = initial.frame.layout_version;
|
||||
assert_eq!(initial.frame.mounts.last().unwrap().x, 158.0);
|
||||
let first = std::collections::BTreeMap::from([(
|
||||
crate::window::MAIN_WINDOW,
|
||||
crate::layout::Size {
|
||||
width: 800.0,
|
||||
height: 600.0,
|
||||
},
|
||||
)]);
|
||||
for _ in 0..20 {
|
||||
session.resize_windows_incremental(&first, false).unwrap();
|
||||
if session.candidate.vm.has_suspended_call() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(session.candidate.vm.has_suspended_call());
|
||||
assert_eq!(
|
||||
session.documents[&crate::window::MAIN_WINDOW]
|
||||
.frame
|
||||
.layout_version,
|
||||
old_version
|
||||
);
|
||||
let latest = std::collections::BTreeMap::from([(
|
||||
crate::window::MAIN_WINDOW,
|
||||
crate::layout::Size {
|
||||
width: 900.0,
|
||||
height: 650.0,
|
||||
},
|
||||
)]);
|
||||
session.resize_windows_incremental(&latest, false).unwrap();
|
||||
assert!(!session.candidate.vm.has_suspended_call());
|
||||
let settled = session.resize_windows(&latest).unwrap().unwrap();
|
||||
assert_eq!(settled.frame.mounts.last().unwrap().x, 158.0);
|
||||
assert_eq!(settled.frame.mounts.last().unwrap().width, 2.0);
|
||||
assert_eq!(source_measure_stat(&mut session, "layoutCancels"), 1);
|
||||
assert!(source_measure_stat(&mut session, "layoutSlices") > 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn idle_tasks_wait_for_prior_callback_refresh_before_next_delivery() {
|
||||
let (mut session, initial) = ReplSession::load(
|
||||
"state = ui.state(0)\npage = Page()\npage.render(ui.textOf(state,\"value\"))\na = ui.after(ui,\"a\",0,state.increment)\nb = ui.after(ui,\"b\",0,state.increment)",
|
||||
"app.main", 274, 1,
|
||||
).unwrap();
|
||||
let old_version = initial.unwrap().frame.layout_version;
|
||||
let viewports = std::collections::BTreeMap::new();
|
||||
assert!(
|
||||
session
|
||||
.poll_tasks_incremental(&viewports)
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
assert!(session.has_pending_refresh());
|
||||
assert!(
|
||||
session
|
||||
.poll_tasks_incremental(&viewports)
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
assert_eq!(
|
||||
session.documents[&crate::window::MAIN_WINDOW]
|
||||
.frame
|
||||
.layout_version,
|
||||
old_version
|
||||
);
|
||||
let first = session.resize_windows(&viewports).unwrap().unwrap();
|
||||
assert!(first.frame.layout_version > old_version);
|
||||
assert_eq!(
|
||||
session.execute("state.value", "app.main").unwrap().value,
|
||||
"1"
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("a.status()", "app.main").unwrap().value,
|
||||
"\"completed\""
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("b.status()", "app.main").unwrap().value,
|
||||
"\"pending\""
|
||||
);
|
||||
session.poll_tasks_incremental(&viewports).unwrap();
|
||||
assert!(session.has_pending_refresh());
|
||||
session.resize_windows(&viewports).unwrap();
|
||||
assert_eq!(
|
||||
session.execute("state.value", "app.main").unwrap().value,
|
||||
"2"
|
||||
);
|
||||
assert_eq!(
|
||||
session.execute("b.status()", "app.main").unwrap().value,
|
||||
"\"completed\""
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incremental_viewport_refresh_retains_published_documents_until_complete() {
|
||||
let (mut session, _) = ReplSession::load(
|
||||
|
||||
Reference in New Issue
Block a user