Skip to content

playWaveFile: Don't create a new WavePlayer until after we have waited on the previous thread.#15681

Merged
seanbudd merged 1 commit into
nvaccess:masterfrom
jcsteh:playRace
Oct 26, 2023
Merged

playWaveFile: Don't create a new WavePlayer until after we have waited on the previous thread.#15681
seanbudd merged 1 commit into
nvaccess:masterfrom
jcsteh:playRace

Conversation

@jcsteh

@jcsteh jcsteh commented Oct 25, 2023

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #15311.

Summary of the issue:

When multiple wave files are played asynchronously in rapid succession without any delay between the calls, NVDA can freeze briefly and throw exceptions such as "AttributeError: 'NoneType' object has no attribute 'feed'".

Description of user facing changes

NVDA no longer sometimes freezes briefly when multiple sounds are played in rapid succession.

Description of development approach

Previously, playWaveFile reassigned fileWavePlayer before waiting for the previous thread to complete. If the previous thread was still cleaning up, it might set fileWavePlayer to None after this new assignment. This meant that fileWavePlayer would be None when the new thread tried to run.

Instead, fileWavePlayer is now reassigned after waiting for the previous thread to complete.

In addition, the inner play() function now catches and logs exceptions that occur while trying to play. This would have made this problem a little easier to debug and should make related problems easier to debug in future.

Testing strategy:

Ran this Python console snippet:
import nvwave; nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav")
Before this change, it usually freezes and throws exceptions. After this change, it does not.

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 October 25, 2023 10:32
@jcsteh jcsteh requested a review from seanbudd October 25, 2023 10:32

@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.

Looks good, could you please add a changelog entry under bug fixes? We recently changed process to require contributors to add these.

@seanbudd seanbudd merged commit 1442068 into nvaccess:master Oct 26, 2023
@nvaccessAuto nvaccessAuto added this to the 2024.1 milestone Oct 26, 2023
@jcsteh jcsteh deleted the playRace branch May 25, 2026 04:04
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 briefly with WASAPI enabled and receives AttributeError: 'NoneType' object has no attribute 'feed'

3 participants