perf: frame-limit Pen and Pencil interactions#125
Conversation
dompm
left a comment
There was a problem hiding this comment.
The shared resolver and Pencil buffer are useful improvements, but the Pen half does not yet meet the isolation checkpoint.
- [P1] Keep Pen preview state out of
ResultPanel. The scheduled hover callback still invokes five panel-level setters. React batches them, butResultPanelstill rerenders and rebuilds its piece element map and surrounding UI once per hover frame. The plan calls for one Pen snapshot consumed by a focused overlay/status subscriber so stable panel work is skipped. - [P2] Refresh the stationary-Shift resolver. The global keyboard effect depends only on
activeTool, so it captures the resolver/index/project geometry from the render in which Pen was activated. If geometry or crop changes while the tool stays Pen (for example after committing a polygon), Shift press/release at a stationary cursor resolves against stale data. Keep the latest resolver in a ref or otherwise refresh the handler without losing keyboard behavior. - [P2] Cancel queued hover work when clearing Pen UI. Pointer leave and tool changes clear state but do not cancel the pending animation-frame task. A previously scheduled task can run afterward and restore a stale hover/guides, including when Pen is selected again. Cancel the scheduler at every preview-cancellation boundary and add a scheduler race test.
Pencil does retain every raw tuple and removes the growing immutable copy from the raw-event path. Its drawing snapshot still copies the cumulative flat buffer once per frame, so describe the win as “no cumulative copy per raw event,” not no cumulative copies at all.
0e3a6ce to
7ddd236
Compare
Deploying vitrai with
|
| Latest commit: |
27f999f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://199e6238.vitrai.pages.dev |
| Branch Preview URL: | https://codex-interaction-pen-pencil.vitrai.pages.dev |
dompm
left a comment
There was a problem hiding this comment.
The local Pen preview state is isolated, and the stale-resolver/cancellation fixes look correct. One high-frequency path still defeats that isolation:
- [P1] Keep Pen status out of
Appstate. Every preview update runsonStatusChange, which issetPenStatusinApp. That produces a new status object every frame, rerendersApp, and invokes the non-memoizedResultPanelagain. In other words, the overlay host's local state no longer directly rerenders the panel, but its status effect immediately causes the same broad render through the parent. Put the Pen status in the same stable external snapshot/controller and let only a focused status-bar subscriber render it (or provide an equivalently isolated route). Add a count test using the real status callback boundary, not only the preview host.
The unused isShiftDown panel state can also be removed; it is no longer read and is still part of the documented TypeScript baseline.
8d9481f to
e06506d
Compare
1d00b43 to
30bc4d5
Compare
* perf: frame-limit viewport gesture publication * perf: move viewport gestures into focused store subscribers * perf: narrow viewport subscriptions around stable canvas children * perf: keep glass pieces idle during pan * perf: index Pen snapping with reference parity (#127) * perf: index pen snapping with reference parity * perf: cache shift-alignment snap queries * fix: preserve project order in length snapping * test: randomize equal-length snap parity * fix: preserve current snapping behavior on indexed path
* perf: add interaction fixtures and behavior baselines * perf: cache piece geometry and memoize canvas pieces * perf: isolate stable and interaction canvas layers * perf: preview piece transforms outside project state * fix: address interaction foundation review feedback * fix: preserve debug mask composition backdrop * perf: frame-limit Pen and Pencil interactions (#125) * perf: frame-limit pen and pencil interaction controllers * fix: refresh and cancel scheduled pen previews * perf: isolate pen preview from result panel * perf: isolate pen status from app state * perf: frame-limit viewport gesture publication (#126) * perf: frame-limit viewport gesture publication * perf: move viewport gestures into focused store subscribers * perf: narrow viewport subscriptions around stable canvas children * perf: keep glass pieces idle during pan * perf: index Pen snapping with reference parity (#127) * perf: index pen snapping with reference parity * perf: cache shift-alignment snap queries * fix: preserve project order in length snapping * test: randomize equal-length snap parity * fix: preserve current snapping behavior on indexed path
Summary
Why
This reduces repeated pointer-path allocation and computation while preserving exact click-time snapping and every raw Pencil sample.
Stack
Depends on #123 (
codex/interaction-performance).Verification
This is a draft pending performance review and browser regression testing.