Skip to content

WasapiWavePlayer: Don't explicitly remove the instance from the instances map in the destructor.#15754

Merged
seanbudd merged 2 commits into
nvaccess:masterfrom
jcsteh:wasapiDel
Nov 7, 2023
Merged

WasapiWavePlayer: Don't explicitly remove the instance from the instances map in the destructor.#15754
seanbudd merged 2 commits into
nvaccess:masterfrom
jcsteh:wasapiDel

Conversation

@jcsteh

@jcsteh jcsteh commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #15752.

Summary of the issue:

Some users sometimes see errors like this in their logs, accompanied by long freezes:

ERROR - stderr (15:18:17.518) - MainThread (29504):
Exception ignored in:
ERROR - stderr (15:18:17.529) - MainThread (29504):
<function WasapiWavePlayer.__del__ at 0x0467A6B8>
ERROR - stderr (15:18:17.950) - MainThread (29504):
Traceback (most recent call last):
ERROR - stderr (15:18:18.392) - MainThread (29504):
  File "nvwave.pyc", line 843, in __del__
ERROR - stderr (15:18:18.830) - MainThread (29504):
  File "weakref.pyc", line 145, in __delitem__
ERROR - stderr (15:18:18.843) - MainThread (29504):
KeyError
ERROR - stderr (15:18:18.855) - MainThread (29504):
:
ERROR - stderr (15:18:19.283) - MainThread (29504):
80057872

Description of user facing changes

NVDA no longer sometimes freezes when speaking a large amount of text.

Description of development approach

Previously, WasapiWavePlayer's __del__ method removed itself from the _instances map. However, a WeakValueDictionary actually removes the reference itself when the object dies. A weakref callback can run before __del__ in some cases, which would mean that the item was already removed, resulting in this KeyError.

To fix this, we just don't explicitly remove the item and rely entirely on WeakValueDictionary to do this.

Testing strategy:

I can't reproduce this, but @beqabeqa473 confirmed that this change seems to fix the issue.

Known issues with pull request:

None.

Code Review Checklist:

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

@jcsteh jcsteh requested a review from a team as a code owner November 7, 2023 13:48
@jcsteh jcsteh requested a review from seanbudd November 7, 2023 13:48

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @jcsteh

@seanbudd seanbudd merged commit cb35653 into nvaccess:master Nov 7, 2023
@nvaccessAuto nvaccessAuto added this to the 2024.1 milestone Nov 7, 2023
@jcsteh jcsteh deleted the wasapiDel branch June 26, 2024 04:42
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.

NVDA freezes when using wasapi

3 participants