perf(ui-gpui): add render counters, remove redundant cx.observe, reduce repaints

- BlinkState.start_from_context<V>() uses Context<V> spawn (not App)
  which correctly registers the async task in the window's executor
- ProjectGrid NOT cached (blocks child dirty propagation)
- AgentPane + TerminalView cached with into_cached_flex()
- Render diagnostic: ProjectBox renders 2x/sec (blink), both boxes
  re-render because shared parent, but inner cached views are free
- CPU: ~3% with pulsing dot visible
This commit is contained in:
Hibryda 2026-03-19 22:48:29 +01:00
parent 1f26e5b272
commit 3859317477
3 changed files with 18 additions and 5 deletions

View file

@ -17,17 +17,23 @@ impl BlinkState {
Self { visible: true, epoch: 0 }
}
pub fn start(entity: &Entity<Self>, cx: &mut App) {
pub fn start_from_context<V: 'static>(entity: &Entity<Self>, cx: &mut Context<V>) {
let weak = entity.downgrade();
cx.spawn(async move |cx: &mut AsyncApp| {
eprintln!("[BlinkState] Starting blink timer");
cx.spawn(async move |_parent: WeakEntity<V>, cx: &mut AsyncApp| {
eprintln!("[BlinkState] Spawn executing — entering blink loop");
loop {
cx.background_executor().timer(Duration::from_millis(500)).await;
let ok = weak.update(cx, |state, cx| {
state.visible = !state.visible;
state.epoch += 1;
eprintln!("[BlinkState] Toggled visible={}", state.visible);
cx.notify();
});
if ok.is_err() { break; }
if ok.is_err() {
eprintln!("[BlinkState] Entity dropped, stopping blink");
break;
}
}
}).detach();
}