Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in ApplicationShell#activateWidget #10570

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

colin-grant-work
Copy link
Contributor

What it does

The ApplicationShell#activateWidget method awaits a Promise returned by ApplicationShell#waitForActivation, but that Promise is not guaranteed to be settled. In particular, if the widget in question fails to accept focus within 2 seconds, it will not be set as the ApplicationShell's activeWidget. Because of that, a call to activateWidget can hang indefinitely, and the Promise handlers retain references to the widget that was to be activated even if that widget is later closed.

This code ensures that the Promise returned by waitForActivation will settle so that activateWidget will run to completion.

How to test

  1. Comment out the implementation of onActivateRequest in vsx-extensions-view-container.tsx.
  2. Run the application and open the extensions view using the View menu.
  3. In the console, see a message about the widget's failure to accept focus in a timely fashion.
  4. Close the extensions view widget.
  5. Open the dev tools and take a memory snapshot. Search for VSXExtensionsViewContainer
  6. You should not see any retained references, and in particular, you should not see this as a retainer:

image

That chain indicates that the view container is being retained (in part) because of the promise in ApplicationShell#activateWidget.

Review checklist

Reminder for reviewers

@colin-grant-work colin-grant-work added quality issues related to code and application quality shell issues related to the core shell labels Dec 21, 2021
@colin-grant-work colin-grant-work merged commit 2352920 into master Jan 5, 2022
@colin-grant-work colin-grant-work deleted the bugfix/activation-memory-leak branch January 5, 2022 20:44
@vince-fugnitto vince-fugnitto added this to the 1.22.0 milestone Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality issues related to code and application quality shell issues related to the core shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants