test: cover viewport replacement with saved mount and task ownership
Verify Tessera GUI / verify (push) Failing after 8m33s

This commit is contained in:
2026-10-23 01:38:18 +08:00
parent d452b95e57
commit 4df99cb2aa
4 changed files with 74 additions and 0 deletions
+3
View File
@@ -521,3 +521,6 @@ Pending bridge layouts now retain a Mount checkpoint. cancel_layout_frame closes
New viewport targets now coalesce pending refresh work. The runtime cancels only an unfinished bridge layout, restores its Mount checkpoint, preserves completed per-window drafts/callback effects and restarts traversal with the latest viewport map. refreshRestarts counts target replacements; layoutCancels counts replacements that actually closed a pending VM layout. Unchanged targets resume the same job. A new external target resets its convergence budget; internal settling does not. Ordinary source/event mutations still serialize behind refresh rather than roll back application effects.
Cancellation checkpoints own explicit VM roots until restored or released. Initial presentations may have no mount dictionary; cancellation restores that absence too. Saved metadata values retain object-valued attributes. A pending refresh can restart while keeping already completed window drafts; no onMount/onUnmount callback is replayed merely because the viewport target changed. Mount-owned tasks are cancelled immediately before an actual onUnmount callback, never during abandoned preparation.
+3
View File
@@ -176,3 +176,6 @@ Pending bridge layouts now retain a Mount checkpoint. cancel_layout_frame closes
New viewport targets now coalesce pending refresh work. The runtime cancels only an unfinished bridge layout, restores its Mount checkpoint, preserves completed per-window drafts/callback effects and restarts traversal with the latest viewport map. refreshRestarts counts target replacements; layoutCancels counts replacements that actually closed a pending VM layout. Unchanged targets resume the same job. A new external target resets its convergence budget; internal settling does not. Ordinary source/event mutations still serialize behind refresh rather than roll back application effects.
Cancellation checkpoints own explicit VM roots until restored or released. Initial presentations may have no mount dictionary; cancellation restores that absence too. Saved metadata values retain object-valued attributes. A pending refresh can restart while keeping already completed window drafts; no onMount/onUnmount callback is replayed merely because the viewport target changed. Mount-owned tasks are cancelled immediately before an actual onUnmount callback, never during abandoned preparation.
+3
View File
@@ -1173,6 +1173,9 @@ Runtime mutation entry points reject direct calls while refresh work is pending,
New viewport targets now coalesce pending refresh work. The runtime cancels only an unfinished bridge layout, restores its Mount checkpoint, preserves completed per-window drafts/callback effects and restarts traversal with the latest viewport map. refreshRestarts counts target replacements; layoutCancels counts replacements that actually closed a pending VM layout. Unchanged targets resume the same job. A new external target resets its convergence budget; internal settling does not. Ordinary source/event mutations still serialize behind refresh rather than roll back application effects.
Cancellation checkpoints own explicit VM roots until restored or released. Initial presentations may have no mount dictionary; cancellation restores that absence too. Saved metadata values retain object-valued attributes. A pending refresh can restart while keeping already completed window drafts; no onMount/onUnmount callback is replayed merely because the viewport target changed. Mount-owned tasks are cancelled immediately before an actual onUnmount callback, never during abandoned preparation.
## UI host object
Positional arguments only:
+65
View File
@@ -4082,6 +4082,71 @@ page.render(block)
);
}
#[test]
fn new_viewport_cancels_pending_layout_and_restores_saved_mount_context() {
let children = std::iter::repeat_n("item", 40)
.collect::<Vec<_>>()
.join(", ");
let source = format!(
"class Wide: Row {{\n function measure(self: Wide, mount: Mount, constraints: Constraints): MeasureResult {{ return MeasureResult(340, 60) }}\n}}\nitem = RectBlock(2, 20)\npage = Page()\npage.render(Wide(0, 0, {children}))"
);
let (mut session, _) = ReplSession::load(&source, "app.main", 272, 1).unwrap();
session.execute("saved = item.mounts().at(0)\nreceived = ui.state(0)\ntoken = ui.after(saved, \"keep\", 60000, received.set)", "app.main").unwrap();
let globals = session.candidate.globals.unwrap();
let Value::Object(saved) = session
.candidate
.vm
.dict_get(globals, &Value::Text("saved".into()))
.unwrap()
.unwrap()
else {
panic!("saved Mount");
};
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());
let latest = std::collections::BTreeMap::from([(
crate::window::MAIN_WINDOW,
crate::layout::Size {
width: 900.0,
height: 650.0,
},
)]);
assert!(
session
.resize_windows_incremental(&latest, false)
.unwrap()
.is_none()
);
assert!(!session.candidate.vm.has_suspended_call());
let mount = session
.candidate
.vm
.payload::<crate::mount::Mount>(saved, "Mount")
.unwrap();
assert!(mount.mounted);
assert!(mount.layout.is_none());
assert_eq!(mount.geometry.width, 2.0);
assert!(session.resize_windows(&latest).unwrap().is_some());
assert!(!session.is_faulted());
assert_eq!(
session.execute("token.status()", "app.main").unwrap().value,
"pending"
);
assert_eq!(source_measure_stat(&mut session, "layoutCancels"), 1);
}
#[test]
fn incremental_viewport_refresh_retains_published_documents_until_complete() {
let (mut session, _) = ReplSession::load(