Properly destroy Add-on Store dialog when it is closed#16019
Merged
Conversation
7b6795d to
b3cc188
Compare
Member
|
Thanks @lukaszgo1 for hunting this down - please go ahead with both PRs to master when you can |
seanbudd
approved these changes
Jan 9, 2024
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.
5 tasks
seanbudd
pushed a commit
that referenced
this pull request
Jan 23, 2024
…zerHelper to decrease likelihood of circular references in NVDA's GUI (#16079) Related to #16019 Summary of the issue: BoxSizerHelper class stores a strong reference to its parent. When it is mistakenly assigned to a member of its parent a circular reference is created making it impossible for Python's garbage collector to destroy the dialog when it goes out of scope. Description of user facing changes Should not be noticeable. Description of development approach BoxSizerHelper now stores a weak reference to its parent.
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.
Nael-Sayegh
pushed a commit
to Nael-Sayegh/nvda
that referenced
this pull request
Feb 15, 2024
…zerHelper to decrease likelihood of circular references in NVDA's GUI (nvaccess#16079) Related to nvaccess#16019 Summary of the issue: BoxSizerHelper class stores a strong reference to its parent. When it is mistakenly assigned to a member of its parent a circular reference is created making it impossible for Python's garbage collector to destroy the dialog when it goes out of scope. Description of user facing changes Should not be noticeable. Description of development approach BoxSizerHelper now stores a weak reference to its parent.
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.
SaschaCowley
pushed a commit
to SaschaCowley/nvda
that referenced
this pull request
Feb 27, 2024
…zerHelper to decrease likelihood of circular references in NVDA's GUI (nvaccess#16079) Related to nvaccess#16019 Summary of the issue: BoxSizerHelper class stores a strong reference to its parent. When it is mistakenly assigned to a member of its parent a circular reference is created making it impossible for Python's garbage collector to destroy the dialog when it goes out of scope. Description of user facing changes Should not be noticeable. Description of development approach BoxSizerHelper now stores a weak reference to its parent.
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.
Adriani90
pushed a commit
to Adriani90/nvda
that referenced
this pull request
Mar 13, 2024
…zerHelper to decrease likelihood of circular references in NVDA's GUI (nvaccess#16079) Related to nvaccess#16019 Summary of the issue: BoxSizerHelper class stores a strong reference to its parent. When it is mistakenly assigned to a member of its parent a circular reference is created making it impossible for Python's garbage collector to destroy the dialog when it goes out of scope. Description of user facing changes Should not be noticeable. Description of development approach BoxSizerHelper now stores a weak reference to its parent.
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.
Opened against beta, since even though the issue was not introduced in 2024.1 development cycle, its effect can be quite serious. Additionally this change is small and very low risk.
Link to issue number:
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:
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
BoxSizerHelperobjects was stored on the store dialog. Since eachBoxSizerHelperalso 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 theBoxSizerHelperon the instance - it is either used as a local variable, or passed to the method which needs it as an parameter.Testing strategy:
gui.settingsDialogs.SettingsDialog._instanceswhen the Add-on Store dialog is closedKnown issues with pull request:
BoxSizerHelperas 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 masterCode Review Checklist: