perf(phoenix-ng): isolate animation loop outside NgZone#877
Open
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
Open
perf(phoenix-ng): isolate animation loop outside NgZone#877GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
Conversation
There was a problem hiding this comment.
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
NgZoneintoEventDisplayService. - Override
EventDisplayService.init()to run the PhoenixEventDisplayinitialization 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
903819e to
b8e1f98
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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