Skip to content

fix(sdk): avoid viewport layout reads on every event - #1640

Open
absorbb wants to merge 1 commit into
newjitsufrom
fix/sdk-viewport-cache
Open

absorbb wants to merge 1 commit into
newjitsufrom
fix/sdk-viewport-cache

Conversation

@absorbb

@absorbb absorbb commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Sending browser events read window.innerWidth and window.innerHeight every time, which can force synchronous layout after a page changes. Cache those dimensions when the browser runtime initializes and refresh them on resize.

The cache and listener are shared per Window, including when payload adjustment recreates a runtime. Screen dimensions and pixel density stay live; each payload still gets its own screen object. Server and custom runtimes are unchanged.

Validation:

  • All 21 SDK Node tests pass, including getter-count, shared-listener, resize, payload-isolation, and server-runtime coverage.
  • SDK TypeScript compilation and all distribution bundles build successfully.
  • Browser suite: 14 passed, 1 skipped, using local Chrome. The new regression test verifies repeated events after DOM changes do not read viewport dimensions, and events after a resize contain updated dimensions.
  • Small-tier local review passed.

The reported client-side 60 ms timing has not been reproduced; the regression checks geometry reads directly rather than timing. Delivery requires publishing the updated SDK/tracking bundle; no console deployment is involved.

@jitsu-code-review jitsu-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review of 1f76b13bc49215beba928bd0e2189bfff14b137c

Reviewed the full diff and relevant runtime callers. No high-confidence defects found. Tests were not run because dependencies are not installed.

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