Add-on Store: prevent duplicate instances from opening#15105
Merged
Conversation
See test results for failed build of commit bf47e7bfd1 |
michaelDCurran
approved these changes
Jul 9, 2023
6 tasks
5 tasks
seanbudd
pushed a commit
that referenced
this pull request
Jan 9, 2024
Related to #15041 and #15105 Summary of the issue: Ever since Add-on Store was introduced NVDA was intermittently failing to restart on my machine. This occurred only when I've opened Add-on Store before restarting. After debugging it turned out the following happens: When exiting NVDA had to destroy the store dialog, as it was kept alive due to circular reference The new instance of NVDA tried to wait for the old instance to exit, but since the exit process took extra long due to destroying the dialog the new copy gave up and didn't start Description of user facing changes NVDA should no longer fail to restart intermittently after opening and closing Add-on Store. Description of development approach The reference to one of BoxSizerHelper objects was stored on the store dialog. Since each BoxSizerHelper also stores reference to its parent the store dialog could not be destroyed properly when closing. This circular reference cycle was broken by no longer storing the BoxSizerHelper on the instance - it is either used as a local variable, or passed to the method which needs it as an parameter. Testing strategy: Ensured store dialog is still functioning Stress tested restarting NVDA on a machine where this was failing and verified it restarts successfully every single time Ensured no instances are stored in gui.settingsDialogs.SettingsDialog._instances when the Add-on Store dialog is closed Known issues with pull request: Storing a BoxSizerHelper as a dialog member is an easy mistake to make in the future. I will submit a PR which makes it less likely to occur by storing a weak reference to the parent in the helper instance. Since this is a bigger and more risky change it will target master The approach taken by Add-on Store: prevent duplicate instances from opening #15105 i.e. ignoring the warning about existing instances is sub-optimal. As demonstrated by this PR ignoring these alive references may cause issues in unrelated areas of NVDA. In my opinion we should restore the old behavior i.e. live references should once again cause a warning. If this is fine I'll submit a PR to that effect against master.
5 tasks
seanbudd
pushed a commit
that referenced
this pull request
Jan 22, 2024
…hey are closed (#16054) Follow up from PR #16019 Summary of the issue: Normally it should not be possible to open the same NVDA's settings dialog multiple times. To make sure this does not happen settings dialog constructor verifies if the given dialog is already opened, and either focuses it when it is, or creates a new dialog when it is not. In rare cases the dialog should be destroyed after user closed it, but due to circular reference Python's garbage collector cannot clean it up. Before PR #15105 this was causing an error making it impossible to reopen the dialog. In that PR the behavior was changed, so that when the instance is still kept alive it is just marked as created and reused. As described in PR #16019 when dialogs are not destroyed properly NVDA may malfunction, so having an error and non working dialog is better than a hard to debug error in other part of NVDA. Description of user facing changes This should not have user visible impact, as long as there are no dialogs which fail to be destroyed when they are closed. Description of development approach When there is an existing instance of a given dialog which is marked as destroyed there is an error in the log, and no other instances of this dialog can be created.
Nael-Sayegh
pushed a commit
to Nael-Sayegh/nvda
that referenced
this pull request
Feb 15, 2024
…hey are closed (nvaccess#16054) Follow up from PR nvaccess#16019 Summary of the issue: Normally it should not be possible to open the same NVDA's settings dialog multiple times. To make sure this does not happen settings dialog constructor verifies if the given dialog is already opened, and either focuses it when it is, or creates a new dialog when it is not. In rare cases the dialog should be destroyed after user closed it, but due to circular reference Python's garbage collector cannot clean it up. Before PR nvaccess#15105 this was causing an error making it impossible to reopen the dialog. In that PR the behavior was changed, so that when the instance is still kept alive it is just marked as created and reused. As described in PR nvaccess#16019 when dialogs are not destroyed properly NVDA may malfunction, so having an error and non working dialog is better than a hard to debug error in other part of NVDA. Description of user facing changes This should not have user visible impact, as long as there are no dialogs which fail to be destroyed when they are closed. Description of development approach When there is an existing instance of a given dialog which is marked as destroyed there is an error in the log, and no other instances of this dialog can be created.
SaschaCowley
pushed a commit
to SaschaCowley/nvda
that referenced
this pull request
Feb 27, 2024
…hey are closed (nvaccess#16054) Follow up from PR nvaccess#16019 Summary of the issue: Normally it should not be possible to open the same NVDA's settings dialog multiple times. To make sure this does not happen settings dialog constructor verifies if the given dialog is already opened, and either focuses it when it is, or creates a new dialog when it is not. In rare cases the dialog should be destroyed after user closed it, but due to circular reference Python's garbage collector cannot clean it up. Before PR nvaccess#15105 this was causing an error making it impossible to reopen the dialog. In that PR the behavior was changed, so that when the instance is still kept alive it is just marked as created and reused. As described in PR nvaccess#16019 when dialogs are not destroyed properly NVDA may malfunction, so having an error and non working dialog is better than a hard to debug error in other part of NVDA. Description of user facing changes This should not have user visible impact, as long as there are no dialogs which fail to be destroyed when they are closed. Description of development approach When there is an existing instance of a given dialog which is marked as destroyed there is an error in the log, and no other instances of this dialog can be created.
Adriani90
pushed a commit
to Adriani90/nvda
that referenced
this pull request
Mar 13, 2024
Related to nvaccess#15041 and nvaccess#15105 Summary of the issue: Ever since Add-on Store was introduced NVDA was intermittently failing to restart on my machine. This occurred only when I've opened Add-on Store before restarting. After debugging it turned out the following happens: When exiting NVDA had to destroy the store dialog, as it was kept alive due to circular reference The new instance of NVDA tried to wait for the old instance to exit, but since the exit process took extra long due to destroying the dialog the new copy gave up and didn't start Description of user facing changes NVDA should no longer fail to restart intermittently after opening and closing Add-on Store. Description of development approach The reference to one of BoxSizerHelper objects was stored on the store dialog. Since each BoxSizerHelper also stores reference to its parent the store dialog could not be destroyed properly when closing. This circular reference cycle was broken by no longer storing the BoxSizerHelper on the instance - it is either used as a local variable, or passed to the method which needs it as an parameter. Testing strategy: Ensured store dialog is still functioning Stress tested restarting NVDA on a machine where this was failing and verified it restarts successfully every single time Ensured no instances are stored in gui.settingsDialogs.SettingsDialog._instances when the Add-on Store dialog is closed Known issues with pull request: Storing a BoxSizerHelper as a dialog member is an easy mistake to make in the future. I will submit a PR which makes it less likely to occur by storing a weak reference to the parent in the helper instance. Since this is a bigger and more risky change it will target master The approach taken by Add-on Store: prevent duplicate instances from opening nvaccess#15105 i.e. ignoring the warning about existing instances is sub-optimal. As demonstrated by this PR ignoring these alive references may cause issues in unrelated areas of NVDA. In my opinion we should restore the old behavior i.e. live references should once again cause a warning. If this is fine I'll submit a PR to that effect against master.
Adriani90
pushed a commit
to Adriani90/nvda
that referenced
this pull request
Mar 13, 2024
…hey are closed (nvaccess#16054) Follow up from PR nvaccess#16019 Summary of the issue: Normally it should not be possible to open the same NVDA's settings dialog multiple times. To make sure this does not happen settings dialog constructor verifies if the given dialog is already opened, and either focuses it when it is, or creates a new dialog when it is not. In rare cases the dialog should be destroyed after user closed it, but due to circular reference Python's garbage collector cannot clean it up. Before PR nvaccess#15105 this was causing an error making it impossible to reopen the dialog. In that PR the behavior was changed, so that when the instance is still kept alive it is just marked as created and reused. As described in PR nvaccess#16019 when dialogs are not destroyed properly NVDA may malfunction, so having an error and non working dialog is better than a hard to debug error in other part of NVDA. Description of user facing changes This should not have user visible impact, as long as there are no dialogs which fail to be destroyed when they are closed. Description of development approach When there is an existing instance of a given dialog which is marked as destroyed there is an error in the log, and no other instances of this dialog can be created.
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.
Link to issue number:
Closes #15041
Summary of the issue:
A reference to the add-on store is kept alive after being destroyed.
It is unclear what is causing this.
If a reference is kept alive, handling a new instance causes an error, allowing multiple instances of the add-on store dialog to be opened.
Description of user facing changes
Prevent multiple instances of the add-on store dialog from opening.
Suppress the ERROR level log when an instance is kept alive to debugWarning, and instead handle the "dead" instance more gracefully.
Description of development approach
Improve the initialisation and destruction of the add-on store with the goal of reducing references to the add-on store dialog from being held.
This is not effective at preventing the add-on store dialog reference from staying alive, but may help solve the problem in future.
It is unclear how the dialog instance is remaining alive, and where the reference is being held.
If an instance is being kept alive, instead of throwing an error when starting a new instance, mark the instance as alive and re-use the alive instance.
Testing strategy:
Test opening and closing the add-on store through the close button, the "x" button for the window and escape.
Known issues with pull request:
The add-on store dialog instance is still being kept alive, when it should die when the add-on store is closed.
Change log entries:
N/A
Code Review Checklist: