Skip to content

Fix freezing of live results view#1578

Merged
koesie10 merged 2 commits intomainfrom
koesie10/mrva-performance
Oct 11, 2022
Merged

Fix freezing of live results view#1578
koesie10 merged 2 commits intomainfrom
koesie10/mrva-performance

Conversation

@koesie10
Copy link
Copy Markdown
Member

It's probably easiest to review this PR commit-by-commit; these also contain some more detailed information about why certain things are necessary. In summary, on every rerender we were registering a new message listener. This would cause every message sent by the extension to trigger N+1 rerenders for the Nth render. The renders would look as follows:

  1. 1 message listener, new listener registered. Total rerenders: 1
  2. 2 message listeners, new listener registered. Total rerenders: 2
  3. 3 message listeners, new listener registered. Total rerenders: 3
  4. 4 message listeners, new listener registered. Total rerenders: 4

This would continue forever and would sometimes result in 10's of thousands of renders happening. This caused the live results view to be unresponsive until no more messages were being sent.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

When the variant analysis view was being rerendered, we were also
reregistering the message listeners, while not deregistering the old
ones. This resulted in a loop of message listeners being registered,
and the variant analysis being rerendered every time a message was
received by one of the listeners. This will ensure that the listener
is only registered once to prevent this from happening.
This cleanup function would never be called in normal operation, but if
we do decide to add a dependency to this `useEffect`, this will ensure
that only one listener is registered at a time.
@koesie10 koesie10 requested a review from a team as a code owner October 11, 2022 14:34
Copy link
Copy Markdown
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

Good catch! I guess this is technically a problem in other views as well?

@koesie10
Copy link
Copy Markdown
Member Author

Yes, this would also be a problem in other views. However, those other views only receive 1 or 2 messages, so those don't run into the same problem. I'll open another PR to fix it for the compare and remote queries views (the results view does handle it correctly).

@koesie10 koesie10 merged commit 0d057ae into main Oct 11, 2022
@koesie10 koesie10 deleted the koesie10/mrva-performance branch October 11, 2022 14:48
@aeisenberg
Copy link
Copy Markdown
Contributor

aeisenberg commented Oct 11, 2022

Thanks for catching this. We'll have to do the same for our other views. Tracking this in #1582.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants