Skip to content

perf(core): avoid unnecessary motion-blur callback replays - #6904

Open
Muzzy5150 wants to merge 1 commit into
heygen-com:mainfrom
Muzzy5150:perf/motion-blur-event-scan-identity
Open

Muzzy5150 wants to merge 1 commit into
heygen-com:mainfrom
Muzzy5150:perf/motion-blur-event-scan-identity

Conversation

@Muzzy5150

Copy link
Copy Markdown
Contributor

What

Make the eventful and silent motion-blur discovery passes compare geometry by stable DOM element identity. Style-only callbacks and earlier-sibling insertion no longer make independent movers appear callback-dependent.

The change is intentionally limited to the event-dependency decision. It does not implement the broader scan caching or tier-handoff work discussed in #6867.

Why

On untouched upstream, deterministic regressions produced four failures with 139 passing tests:

  • An opacity-only callback set readEvents=true even though the callback did not move either element.
  • Inserting a sibling before an existing mover set readEvents=true because the mover changed snapshot-local array index.
  • Both capture and filter tiers replayed callbacks five times for one preview frame: four pose samples plus frame restoration.

The synthetic discovery workload performed 31 eventful callback invocations and 62 seeks in total, found the same single mover, and ended at the same 300 px geometry. The scan work remains 62 seeks after this change, but unnecessary per-frame callback replays fall from 5 to 0.

Related work

Refs #6867.

This preserves the eventful-first scan, callback landing behavior, animated-ancestor coverage, and root-last restoration established by #6865.

How

  • Record per-step boxes in maps keyed by each HTMLElement.
  • During the silent pass, read boxes for the elements found dynamic by the eventful pass even when a callback-only style remains at its final value.
  • Compare the same elements at the same 1/64 px precision.
  • Treat a missing eventful element or changed box as callback-dependent, while ignoring quiet-only ordering changes.

Real callback-controlled movement still produces readEvents=true. No public API, dependency, capture tier, filter tier, or seek ordering changes.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (not applicable; this is internal discovery behavior)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Automated results:

  • Focused discovery and integration tests: 143 passed
  • Motion-blur plus GSAP adapter tests: 271 passed
  • Full @hyperframes/core suite: 5,650 passed
  • Core runtime contract/coverage gate: 2,691 passed; Hyperframe linter passed
  • Workspace typecheck, lint, format check, build, comment citation, comment ratchet, and Fallow audit passed

A real Chrome/GSAP probe confirmed readEvents=false for opacity-only and insertion cases, while genuine callback-driven movement remains readEvents=true. All three cases retained the expected mover and final geometry.

AI assistance disclosure: OpenAI Codex assisted with investigation, implementation, and test execution. I reviewed the complete diff and verification results.

Compare eventful and silent geometry by stable element identity.

This prevents style-only callbacks and DOM insertion from forcing eventful pose reads.

This branch has not been deployed

No deployments
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