Cache source measurements and propagate native viewport inputs
Verify Tessera GUI / verify (push) Failing after 7m29s
Verify Tessera GUI / verify (push) Failing after 7m29s
This commit is contained in:
+81
-3
@@ -93,6 +93,7 @@ fn start_server_observed(
|
||||
.spawn(move || {
|
||||
let mut worker = Worker::default();
|
||||
loop {
|
||||
worker.refresh_viewport(&worker_namespace, &worker_notify);
|
||||
match receiver.recv_timeout(std::time::Duration::from_millis(100)) {
|
||||
Ok(job) => {
|
||||
let response = worker.run(&job, &worker_namespace, &worker_notify);
|
||||
@@ -297,6 +298,18 @@ fn code_request(
|
||||
"X-Tessera-Layout-Version",
|
||||
¤t.document.frame.layout_version.to_string(),
|
||||
);
|
||||
if let Some(viewport) = current.viewport {
|
||||
add_header(
|
||||
&mut response,
|
||||
"X-Tessera-Viewport-Width",
|
||||
&viewport.width.to_string(),
|
||||
);
|
||||
add_header(
|
||||
&mut response,
|
||||
"X-Tessera-Viewport-Height",
|
||||
&viewport.height.to_string(),
|
||||
);
|
||||
}
|
||||
add_header(
|
||||
&mut response,
|
||||
"X-Tessera-Source-Kind",
|
||||
@@ -412,6 +425,55 @@ struct Worker {
|
||||
next_session: u64,
|
||||
}
|
||||
impl Worker {
|
||||
fn refresh_viewport(&mut self, namespace: &Arc<RwLock<NamespaceState>>, notify: &Notify) {
|
||||
let (epoch, viewport) = match namespace.read() {
|
||||
Ok(current) => (current.submission, current.viewport),
|
||||
Err(_) => return,
|
||||
};
|
||||
let Some((owner, runtime)) = &mut self.repl else {
|
||||
return;
|
||||
};
|
||||
if *owner != epoch {
|
||||
self.repl = None;
|
||||
return;
|
||||
}
|
||||
if runtime.is_faulted() {
|
||||
return;
|
||||
}
|
||||
let id = runtime.id;
|
||||
let result = catch_unwind(AssertUnwindSafe(|| runtime.resize(viewport)));
|
||||
let mut current = match namespace.write() {
|
||||
Ok(current) => current,
|
||||
Err(_) => return,
|
||||
};
|
||||
if current.submission != epoch || current.document.frame.session != id {
|
||||
return;
|
||||
}
|
||||
let document = match result {
|
||||
Ok(Ok(Some(document))) => document,
|
||||
Ok(Ok(None)) => return,
|
||||
failure => {
|
||||
let mut document = current.document.clone();
|
||||
document.frame.fault = Some(match failure {
|
||||
Ok(Err(error)) => format!("Viewport update failed: {error:#}")
|
||||
.chars()
|
||||
.take(1024)
|
||||
.collect(),
|
||||
_ => {
|
||||
self.repl = None;
|
||||
"Runtime discarded after an internal viewport failure".into()
|
||||
}
|
||||
});
|
||||
document
|
||||
}
|
||||
};
|
||||
let changed = matches!(current.commit(epoch, document), Ok(Some(_)));
|
||||
drop(current);
|
||||
if changed {
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
job: &BuildRequest,
|
||||
@@ -424,6 +486,7 @@ impl Worker {
|
||||
if job.kind == RequestKind::Expression {
|
||||
return build(job, namespace, notify);
|
||||
}
|
||||
self.refresh_viewport(namespace, notify);
|
||||
let epoch = match namespace.read() {
|
||||
Ok(current) => current.submission,
|
||||
Err(_) => return error_response(StatusCode(500), "namespace lock is poisoned"),
|
||||
@@ -485,7 +548,8 @@ impl Worker {
|
||||
.is_none_or(|(current, _)| *current != epoch)
|
||||
{
|
||||
self.next_session += 1;
|
||||
match endor_host::ReplSession::new(self.next_session) {
|
||||
let viewport = namespace.read().ok().and_then(|current| current.viewport);
|
||||
match endor_host::ReplSession::new_with_viewport(self.next_session, viewport) {
|
||||
Ok(session) => self.repl = Some((epoch, session)),
|
||||
Err(error) => return error_response(StatusCode(500), error.to_string()),
|
||||
}
|
||||
@@ -572,7 +636,21 @@ impl Worker {
|
||||
};
|
||||
let id = self.next_session;
|
||||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
endor_host::ReplSession::load(&job.source, &job.namespace, job.submission, id)
|
||||
let viewport = namespace
|
||||
.read()
|
||||
.map_err(|_| anyhow::anyhow!("namespace lock poisoned"))?
|
||||
.viewport;
|
||||
if viewport.is_some() {
|
||||
endor_host::ReplSession::load_with_viewport(
|
||||
&job.source,
|
||||
&job.namespace,
|
||||
job.submission,
|
||||
id,
|
||||
viewport,
|
||||
)
|
||||
} else {
|
||||
endor_host::ReplSession::load(&job.source, &job.namespace, job.submission, id)
|
||||
}
|
||||
}));
|
||||
let Ok(mut current) = namespace.write() else {
|
||||
return error_response(StatusCode(500), "namespace lock poisoned");
|
||||
@@ -770,7 +848,7 @@ declarations, explicit first `self` parameters, positional field construction an
|
||||
member assignment. Inherited methods bind the actual receiver; overridden methods
|
||||
are dynamically selected through self. Concrete native visual subclasses reuse real native allocators; abstract bases remain unconstructible. Traits and annotation checking remain pending. Native Block/Page methods use the same type method tables and binding path.
|
||||
|
||||
Source measure and arrange overrides execute bottom-up and top-down in one read-only VM layout call. Structural Mount links exist before first measurement; bounds queries reject premature geometry. Native base layout uses current occurrence child measurements, and Arrangement must assign every stable child slot exactly once. Layout dependencies changed by lifecycle hooks trigger another pass before publication. Constraints are currently finite/unconstrained page inputs; viewport propagation and source measurement caching remain pending.
|
||||
Source measure and arrange overrides execute bottom-up and top-down in one read-only VM layout call. Structural Mount links exist before first measurement; bounds queries reject premature geometry. Native base layout uses current occurrence child measurements, and Arrangement must assign every stable child slot exactly once. Layout dependencies changed by lifecycle hooks trigger another pass before publication. Page constraints now use the current logical window viewport. Column/Button propagate cross-axis width and Row propagates cross-axis height; desired sizes are clamped. ui.viewport() provides a managed snapshot whose private input participates in rendering dependencies. Native resize updates are coalesced on the same worker without adding source inputs. Source measurement caches use Mount/method/children/constraints and actual subcall object reads, including returned-result decoding; Mount-reading methods conservatively bypass caching. ui.stats() exposes sourceMeasureHits/sourceMeasureMisses outside read-only rendering. General constraint negotiation, wrapping and scrolling remain pending.
|
||||
|
||||
Source paint overrides execute in the actual frame pipeline under a read-only heap policy. Source hitTest overrides similarly refine native pointer targets in VM paint order; Point.inside(bounds) and Point.inCircle(cx, cy, radius) provide primitive shape queries. Managed DisplayList/ObjectList/PaintCommand and Constraints/Bounds/Point results are ordinary runtime objects.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user