Skip to content

NVDA freezes briefly with WASAPI enabled and receives AttributeError: 'NoneType' object has no attribute 'feed' #15311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cary-rowen opened this issue Aug 18, 2023 · 16 comments · Fixed by #15681
Labels
bug/regression component/audio NVDA's audio output (nvWave, issues with usb audio etc). p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@cary-rowen
Copy link
Contributor

cc @jcsteh Maybe you can take a look at this Issue.

Steps to reproduce:

This issue may require a specific add-on to reproduce, but I've confirmed that it can only be reproduced with WASAPI enabled.

  1. Install ClipBoardEnhancement add-on.
  2. Please press Ctrl+C copy a file to the system clipboard at will.
  3. Press Ctrl+Numpad7/Numpad9.
    • Laptop: NVDA+Alt+UpArrow/DownArrow
    • The function of this gesture is to report the name and path of the file in the clipboard.
    • nvwave.playWaveFile is called in the process.
  4. Repeat step (3) repeatedly.
  5. When performing steps (3) and (4), you can feel that NVDA freezes briefly, and you can find some errors in the log.

Actual behavior:

Found the following in the NVDA log:

IO - inputCore.InputManager.executeGesture (18:54:14.232) - winInputHook (8472):
Input: kb(laptop):alt+NVDA+downArrow
ERROR - stderr (18:54:16.126) - nvwave.playWaveFile(FileInClipboard.wav) (9880):
Exception in thread nvwave.playWaveFile(FileInClipboard.wav):
Traceback (most recent call last):
  File "threading.pyc", line 926, in _bootstrap_inner
  File "threading.pyc", line 870, in run
  File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'

Expected behavior:

NVDA should not brief freezes without 'AttributeError'.

NVDA logs, crash dumps and other attachments:

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

alpha-28879,a7981cad

Windows version:

Windows 10 22H2 (AMD64) build 19045.3324

Name and version of other software in use when reproducing the issue:

None

Other information about your system:

None

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

nvda-2023.2Beta3 can also reproduce this as long as WASAPI is enabled.

If NVDA add-ons are disabled, is your problem still occurring?

No

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

Yes

@zstanecic
Copy link
Contributor

zstanecic commented Aug 18, 2023 via email

@cary-rowen
Copy link
Contributor Author

"AttributeError: 'NoneType' object has no attribute 'feed'"

I've also observed this error with other add-ons that use nvwave.playWaveFile, but it doesn't freeze NVDA.
such as: https://github.com/nvda-es/TeleNVDA

@seanbudd seanbudd added this to the 2023.3 milestone Aug 21, 2023
@seanbudd seanbudd added p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation. component/audio NVDA's audio output (nvWave, issues with usb audio etc). labels Aug 21, 2023
@seanbudd
Copy link
Member

cc @jcsteh - @cary-rowen, this may be fixed in the next alpha build (building soon)

@jcsteh
Copy link
Contributor

jcsteh commented Aug 31, 2023

I suspect this is a different issue, but it'll be interesting to see. I don't really understand how WASAPI could be causing this.

@seanbudd
Copy link
Member

If this can't be reproduced with add-ons disabled with the latest alpha, we can probably close the issue

@jcsteh
Copy link
Contributor

jcsteh commented Aug 31, 2023

To clarify my previous comment, it looks like fileWavePlayer becomes None. fileWavePlayer is set up the same way regardless of whether it's WASAPI or not. Exceptions can certainly occur within WASAPI, but nothing in the WASAPI code can clear references to the actual instance altogether.

@cary-rowen
Copy link
Contributor Author

I tested the latest alpha-29021 and it can be reproduced.
It should be noted that there is a possibility of encountering this problem even if I disable the add-on, but it cannot be reproduced stably. The reason why I mention this add-on is because I hope to clarify this bug in a feasible way.

@Adriani90
Copy link
Collaborator

This is the only issue I can see so far that might or not be related to Wasapi. This should not prevent Wasapi from becomming the default in 2023.3. as of now using Wasapi is the default only in alpha channel right?

@seanbudd
Copy link
Member

seanbudd commented Sep 8, 2023

WASAPI will be default in the 2023.3beta1 and is current default in alpha. It is not default in 2023.2.

We consider fixing this issue a "nice to have" for 2023.3

@seanbudd seanbudd modified the milestones: 2023.3, 2024.1 Sep 14, 2023
@beqabeqa473
Copy link
Contributor

This issue is still reproduceable.
Are there attempts to fix that?
@jcsteh

@beqabeqa473
Copy link
Contributor

ERROR - stderr (12:01:44.523) - MainThread (13532):
Exception ignored in:
ERROR - stderr (12:01:44.535) - MainThread (13532):
<function WasapiWavePlayer.del at 0x03E59ED0>
ERROR - stderr (12:01:44.949) - nvwave.playWaveFile(error.wav) (16680):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:44.949) - MainThread (13532):
Traceback (most recent call last):
ERROR - stderr (12:01:44.963) - MainThread (13532):
File "nvwave.pyc", line 840, in del
ERROR - stderr (12:01:45.378) - nvwave.playWaveFile(error.wav) (17520):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:45.378) - MainThread (13532):
File "weakref.pyc", line 146, in delitem
ERROR - stderr (12:01:45.391) - MainThread (13532):
KeyError
ERROR - stderr (12:01:45.402) - MainThread (13532):
:
ERROR - stderr (12:01:45.822) - nvwave.playWaveFile(error.wav) (10648):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:45.822) - MainThread (13532):
64153688
ERROR - stderr (12:01:45.840) - MainThread (13532):
Exception ignored in:
ERROR - stderr (12:01:45.850) - MainThread (13532):
<function WasapiWavePlayer.del at 0x03E59ED0>
ERROR - stderr (12:01:46.267) - nvwave.playWaveFile(error.wav) (15236):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:46.267) - MainThread (13532):
Traceback (most recent call last):
ERROR - stderr (12:01:46.279) - MainThread (13532):
File "nvwave.pyc", line 840, in del
ERROR - stderr (12:01:46.695) - nvwave.playWaveFile(error.wav) (10784):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:46.695) - MainThread (13532):
File "weakref.pyc", line 146, in delitem
ERROR - stderr (12:01:46.708) - MainThread (13532):
KeyError
ERROR - stderr (12:01:47.124) - nvwave.playWaveFile(error.wav) (11032):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'
ERROR - stderr (12:01:47.124) - MainThread (13532):
:
ERROR - stderr (12:01:47.137) - MainThread (13532):
64151768
ERROR - stderr (12:01:47.554) - nvwave.playWaveFile(error.wav) (14288):
Exception in thread nvwave.playWaveFile(error.wav):
Traceback (most recent call last):
File "threading.pyc", line 926, in _bootstrap_inner
File "threading.pyc", line 870, in run
File "nvwave.pyc", line 710, in play
AttributeError: 'NoneType' object has no attribute 'feed'

@jcsteh
Copy link
Contributor

jcsteh commented Oct 25, 2023

As far as I can tell, there is no difference in playWaveFile with WASAPI enabled other than maybe timing. There is no alternative code path for playWaveFile or anything like that. My guess is that this was always possible, but timing meant that it didn't occur in practice with WinMM.

@jcsteh
Copy link
Contributor

jcsteh commented Oct 25, 2023

Does the add-on play sounds from a background thread? I guess that might cause weirdness, but again, that's not unique to WASAPI.

@jcsteh
Copy link
Contributor

jcsteh commented Oct 25, 2023

Ah. Is it possible there are some earlier exceptions in the log? I think the key part might be the weakref KeyError part, rather than the AttributeError part. The weakref part is specific to WASAPI, but I don't know how we're getting into that state.

@jcsteh
Copy link
Contributor

jcsteh commented Oct 25, 2023

Aha. It seems to be due to playing multiple sounds rapidly. You can reproduce it intermittently with this Python console snippet:

import nvwave; nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav"); nvwave.playWaveFile("waves/browseMode.wav")

@beqabeqa473
Copy link
Contributor

beqabeqa473 commented Oct 25, 2023 via email

seanbudd pushed a commit that referenced this issue Oct 26, 2023
…d on the previous thread. (#15681)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/regression component/audio NVDA's audio output (nvWave, issues with usb audio etc). p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
6 participants