Skip to content

Add-on Store: prevent duplicate instances from opening#15105

Merged
seanbudd merged 2 commits into
masterfrom
preventDuplicateAddonStore
Jul 10, 2023
Merged

Add-on Store: prevent duplicate instances from opening#15105
seanbudd merged 2 commits into
masterfrom
preventDuplicateAddonStore

Conversation

@seanbudd

@seanbudd seanbudd commented Jul 7, 2023

Copy link
Copy Markdown
Member

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:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@seanbudd seanbudd requested a review from a team as a code owner July 7, 2023 03:56
@seanbudd seanbudd requested a review from michaelDCurran July 7, 2023 03:56
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit bf47e7bfd1

@seanbudd seanbudd merged commit b7b38c3 into master Jul 10, 2023
@seanbudd seanbudd deleted the preventDuplicateAddonStore branch July 10, 2023 00:02
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Jul 10, 2023
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.
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.
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.

Error message when reopening add-on store

4 participants