Skip to content

Render only the latest pending tracking frame per scene - #45

Merged
Lyptik merged 2 commits into
mainfrom
perf/render-latest-frame
Oct 5, 2026
Merged

Lyptik merged 2 commits into
mainfrom
perf/render-latest-frame

Conversation

@Lyptik

@Lyptik Lyptik commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Why

WebSocket data currently mutates Three.js objects immediately for every received tracking frame, even when several network frames arrive between display refreshes. Those intermediate state frames can never be presented and only add CPU/GC work.

Changes

  • add a bounded pending-frame map keyed by scene
  • WebSocket callbacks only publish the latest frame for each scene
  • consume pending frames from Three.js' existing animation loop immediately before rendering
  • clear pending frames together with tracking state
  • count/debug only frames that are actually presented

Result

Application-side buffering is bounded to one pending frame per scene, and visual state naturally follows the freshest available tracking frame without building a FIFO backlog.

Scope

This intentionally stays in the ThreeJS example/viewer rather than changing the transport-independent JS SDK. Setup/control messages remain immediate. No protocol, polling or compression behavior is changed.

@Lyptik
Lyptik marked this pull request as ready for review October 5, 2026 18:28
@Lyptik
Lyptik merged commit 432530e into main Oct 5, 2026
1 check passed
@Lyptik
Lyptik deleted the perf/render-latest-frame branch October 6, 2026 07:05
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