Skip to content

perf(phoenix-ng): isolate animation loop outside NgZone#877

Open
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:perf/827-ngzone-animation-loop-isolation
Open

perf(phoenix-ng): isolate animation loop outside NgZone#877
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:perf/827-ngzone-animation-loop-isolation

Conversation

@GaneshPatil7517
Copy link
Copy Markdown
Collaborator

Run the Three.js animation loop outside Angular's zone to prevent unnecessary change detection cycles (~60/sec) caused by requestAnimationFrame.

Override EventDisplayService.init() to wrap super.init() inside NgZone.runOutsideAngular(), ensuring the setAnimationLoop callback and all its descendant microtasks execute outside Angular's zone.

Angular UI still re-enters the zone for user-driven events (click, input) since Zone.js patches those globally.

Ref: #827

Copilot AI review requested due to automatic review settings April 9, 2026 12:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve Angular performance in phoenix-ng by preventing Three.js’ requestAnimationFrame-driven animation loop from triggering Angular change detection on every frame.

Changes:

  • Inject NgZone into EventDisplayService.
  • Override EventDisplayService.init() to run the Phoenix EventDisplay initialization outside Angular’s zone.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Move only the Three.js animation loop outside Angular's zone to
prevent ~60 unnecessary change detection cycles per second caused
by requestAnimationFrame.

super.init(configuration) runs inside the zone so that URL-option
loading, event-change callbacks (listenToLoadedEventsChange,
listenToDisplayedEventChange) and other promise/fetch work still
trigger Angular change detection as expected.

After init, re-register the animation loop via
NgZone.runOutsideAngular() so only requestAnimationFrame (Three.js
render + stats update) runs outside the zone.

Ref: HSF#827
@GaneshPatil7517 GaneshPatil7517 force-pushed the perf/827-ngzone-animation-loop-isolation branch from 903819e to b8e1f98 Compare April 9, 2026 13:37
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.

2 participants