Skip to content

perf: frame-limit viewport gesture publication#126

Merged
dompm merged 5 commits into
codex/interaction-pen-pencilfrom
codex/interaction-viewport
Jul 16, 2026
Merged

perf: frame-limit viewport gesture publication#126
dompm merged 5 commits into
codex/interaction-pen-pencilfrom
codex/interaction-viewport

Conversation

@dompm

@dompm dompm commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • coalesce wheel, pan, and pinch viewport publication to animation frames
  • retain immediate mutable viewport values for event-to-event accumulation
  • cancel pending viewport work on unmount

Why

Trackpads and touch devices can emit multiple viewport events per display frame. Coalescing their React publication reduces redundant panel work.

Stack

Depends on #125 (codex/interaction-pen-pencil).

Verification

  • interaction test suite passes
  • production build succeeds
  • no new TypeScript errors beyond the documented baseline

This is a draft pending performance review and browser regression testing.

@dompm dompm left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This coalesces raw viewport events, but it is only the first half of the planned viewport phase.

  • [P1] Do not publish high-frequency viewport state through the owning panel. scheduleViewport still calls setZoom and setPan, so ResultPanel or SheetPanel rerenders in full on every display frame during pan/zoom. That is better than one render per raw event, but it leaves the project-size-dependent React work that phase 5 was intended to remove. Move high-frequency pan/zoom into a stable store/controller and let small viewport groups and DOM-overlay positioners subscribe directly.
  • Add an executable render/publication-count check. The current 25-test suite has no viewport test, so “at most one React publication per frame” is structurally plausible from the code but not currently a scripted acceptance check.

@dompm
dompm force-pushed the codex/interaction-pen-pencil branch from 0e3a6ce to 7ddd236 Compare July 13, 2026 17:33
@dompm
dompm force-pushed the codex/interaction-viewport branch from 83635dd to a5d83ce Compare July 13, 2026 19:22
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying vitrai with  Cloudflare Pages  Cloudflare Pages

Latest commit: 138e0a3
Status: ✅  Deploy successful!
Preview URL: https://741f1548.vitrai.pages.dev
Branch Preview URL: https://codex-interaction-viewport.vitrai.pages.dev

View logs

@dompm dompm left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The store correctly coalesces publication and prevents the ResultPanel/SheetPanel function itself from rerunning. The subscriber is still much broader than the requested architecture:

  • [P1] Subscribe only the viewport transform and positioned overlays. The single ViewportSubscriber currently wraps the complete Stage, every layer, every pieces.map(...), Pen/Pencil overlays, crop/measure UI, and DOM properties UI. Each pan publication therefore recreates and reconciles the full canvas element tree; with hundreds of pieces this retains the project-size-dependent per-frame React work the viewport phase was meant to remove. Use focused subscriber components around each Konva viewport Group and small DOM positioners, with stable children created by the owning panel.
  • The current count test proves that a synthetic parent function is not called, but its subscriber child is only a <span>. Add a regression check with an expensive/stable canvas child (or instrumentation around the real panel subtree) proving pan updates do not recreate/reconcile piece elements.

The browser smoke test confirms pan and overlays remain visually synchronized; this is a performance-architecture blocker, not a visible coordinate regression.

@dompm
dompm force-pushed the codex/interaction-viewport branch from 54ca1ee to aae8e12 Compare July 13, 2026 20:00
@dompm
dompm force-pushed the codex/interaction-viewport branch from d4f3d28 to 289779c Compare July 16, 2026 16:19
@dompm
dompm force-pushed the codex/interaction-pen-pencil branch from 8d9481f to e06506d Compare July 16, 2026 16:19
* 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
@dompm
dompm marked this pull request as ready for review July 16, 2026 16:48
@dompm
dompm merged commit 27f999f into codex/interaction-pen-pencil Jul 16, 2026
2 checks passed
@dompm
dompm deleted the codex/interaction-viewport branch July 16, 2026 16:48
dompm added a commit that referenced this pull request Jul 16, 2026
* 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
dompm added a commit that referenced this pull request Jul 16, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant