Skip to content

Conversation

@MinCrohn
Copy link
Collaborator

The previous ticker-based update logic for Relations caused unnecessary re-rendering, especially during viewport panning, which led to performance degradation.

This has been improved by adopting an event-driven architecture using the onRender callback. Now, the Relations object is re-rendered only when an actual transform change occurs on a linked object, significantly reducing CPU usage and improving the stability and performance of the rendering loop.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @MinCrohn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the rendering efficiency and stability of Relations objects by transitioning from a continuous, ticker-based update mechanism to a more precise, event-driven system. This change ensures that Relations are only re-rendered when their associated linked objects undergo a transformation, thereby reducing CPU usage and improving overall application performance, particularly during interactive operations like viewport panning.

Highlights

  • Performance Optimization: The rendering logic for Relations objects has been refactored to improve performance. Previously, Relations were re-rendered continuously via a ticker, leading to unnecessary updates and performance degradation, especially during viewport panning. This PR switches to an event-driven approach.
  • Event-Driven Rendering: Rendering of Relations objects now occurs only when a linked object's transform changes. This is achieved by introducing a transform_updated event on Base objects, which Relations listen to, ensuring updates are triggered precisely when needed.
  • Code Simplification and Cleanup: The Relations class no longer uses a ticker for updates, removing the _renderOnNextTick flag and the _updateTransform method. The path object is now directly stored as an instance property, eliminating the need for a selector lookup.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the rendering logic for Relations from a ticker-based approach to a more efficient event-driven architecture using onRender. This is a great improvement that correctly triggers re-rendering only when linked objects' transforms change, which should significantly improve performance and fix previous behavior where relations did not update on object movement. The changes in Base.js to emit transform_updated events and in linksable.js to listen for them are well-designed. I've found one high-severity issue in linksable.js where an event listener is not being properly removed, which could lead to memory leaks. Otherwise, the implementation looks solid.

@MinCrohn
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Relations object to use an event-driven rendering approach which will improve performance. There is a bug that prevents new links from rendering immediately and a high-severity issue that could cause an infinite render loop on error. The suggestions aim to fix these issues to ensure the new implementation is both correct and robust.

@MinCrohn
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces an event-driven architecture to re-render the Relations object, improving performance. A potential memory leak in the Linksable mixin was identified due to missing event listener cleanup during object destruction. A suggestion to add a destroy method to remove these listeners has been provided to ensure proper garbage collection.

@MinCrohn
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the rendering logic for Relations to be event-driven using onRender, which improves performance. The new implementation detects transform changes in linked objects and triggers re-rendering only when necessary.

My review includes a fix to prevent a potential crash in the Linksable mixin, along with suggestions to improve code clarity and future maintainability. Overall, the changes are well-structured and achieve the stated goal.

@MinCrohn
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request refactors the Relations object to use an event-driven architecture with the onRender callback, improving rendering performance by reducing unnecessary re-renders. The changes involve removing the ticker-based update logic, introducing _onObjectUpdate to detect transform changes, and updating the renderLink method to use the this.path property directly.

@MinCrohn MinCrohn merged commit b1df5fb into v0.3.x Jul 17, 2025
@MinCrohn MinCrohn deleted the fix/relations-trigger branch July 17, 2025 08: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.

2 participants