Fix callback leaks and stale state during EventDisplay re-initialization#782
Merged
Merged
Conversation
Clear accumulated callbacks in EventDisplay.cleanup() and add StateManager.resetForViewTransition() to prevent memory leaks and stale state when navigating between experiment views. Signed-off-by: remo-lab <remopanda7@gmail.com>
Contributor
Author
|
Hi @EdwardMoyse @sponce |
Member
|
Thank you very much! |
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.
Problem
During repeated initialization of
EventDisplay, callbacks registered across multiple subsystems were not being consistently cleaned up. Specifically, callbacks registered by previous view instances remained referenced afterEventDisplaywas torn down, because cleanup paths did not fully clear stored listeners and stateful references.In addition,
StateManagercontinued to hold references to camera and menu objects from the previous initialization cycle, allowing callbacks tied to destroyed Angular components to remain reachable and executable. As a result, callbacks from older instances causing multiple handlers to fire for a single event.Fix
This change ensures that all callbacks registered during an
EventDisplaylifecycle are explicitly cleared duringEventDisplay.cleanup(). It also resets internal references insideStateManagerso that each re-initialization starts from a clean state. Guards were added to callback execution paths to prevent handlers from running after their owning components have been destroyed.Impact
EventDisplayre-initializationsStateManager