nvaccess / nvda

NVDA, the free and open source Screen Reader for Microsoft Windows
Other
2.07k stars 624 forks source link

Unable to open `ui.browseableMessage` #16806

Closed CyrilleB79 closed 1 month ago

CyrilleB79 commented 2 months ago

This issue happens very rarely, I have had it only twice or 3 times. Restarting NVDA fixes it.

Steps to reproduce:

Use a command that opens a ui.browseableMessage, e.g. press NVDA+f twice quickly in Word.

Actual behavior:

The messages does not open and the error sound is heard.

Expected behavior:

The browseable message should open.

NVDA logs, crash dumps and other attachments:

The following error is logged

ERROR - ui.browseableMessage (10:26:45.685) - MainThread (9444):
Scripting.Dictionary component unavailable
Traceback (most recent call last):
  File "ui.pyc", line 113, in browseableMessage
  File "comtypes\client\__init__.pyc", line 264, in CreateObject
  File "comtypes\client\__init__.pyc", line 181, in _manage
  File "comtypes\client\__init__.pyc", line 115, in GetBestInterface
  File "comtypes\client\_generate.pyc", line 132, in GetModule
  File "comtypes\client\_generate.pyc", line 246, in _create_wrapper_module
  File "comtypes\client\_generate.pyc", line 181, in _create_module_in_file
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Cyrille\\AppData\\Local\\Temp\\comtypes_cache\\nvda-311\\_420B2830_E718_11CF_893D_00A0C9054228_0_1_0.py'

Full log kept privately if needed.

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

2024.3beta1

Windows version:

Windows 10 22H2 (AMD64) build 19045.4529

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

N/A

Other information about your system:

N/A

Other questions

Does the issue still occur after restarting your computer?

Not tested: the issue already disappears after restarting NVDA.

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

I have already had this issue with a previous version of NVDA, i.e. with NVDA 2024.2(rc2) or before.

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

Not able to test, the issue is too rare; I cannot use NVDA without add-ons during days or weeks just to test this.

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

Not tested, but NVDA 2024.3beta1 has just been installed 2 days ago.

CyrilleB79 commented 2 months ago

Cc @michaelDCurran

LeonarddeR commented 2 months ago

It looks like we need to add another builtin com interface to address this:

COM_INTERFACES = {
    "Scripting.py": ("{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0),
}
CyrilleB79 commented 2 months ago

I am not able to understand why it does not work rarely (in some very specific case), but works again when I restart NVDA.

@LeonarddeR could you give me more details? I do not know so much about COM interfaces and how NVDA uses it. Thanks.

LeonarddeR commented 2 months ago

If comtypes needs a com interface wrapper module that is not built in to NVDA, it will magically create a new python module for the type library and saves these in %temp%\comtypes_cache\<executable>-<pythonversion>. In your case, the problem is most likely that comtypes returns to early when trying to load the module, resulting into this file not found error since the module is not yet available on the file system. You might be able to reproduce this much easier if you remove %temp%\comtypes_cache. Adding the line I proposed above to comInterfaces_sconscript will most likely fix this issue, as the module will then be known to NVDA at build time.

CyrilleB79 commented 2 months ago

Thanks @LeonarddeR for your explanation.

If I understand correctly, the file is being created but not available yet during the first call to ui.browseableMessage. However when calling ui.browseableMessage a second time, the file generated during the first call should now be available and this should not fail anymore. But that's not what I am observing.

Or is my reasoning incorrect?

LeonarddeR commented 2 months ago

I assumed your reasoning was correct, but regardless whether you observe something differently, the solution would be the same probably.

CyrilleB79 commented 1 month ago

I have had the issue again this morning:

IO - inputCore.InputManager.executeGesture (09:41:36.952) - winInputHook (20324):
Input: kb(desktop):NVDA+f
ERROR - ui.browseableMessage (09:41:36.990) - MainThread (20472):
Scripting.Dictionary component unavailable
Traceback (most recent call last):
  File "ui.pyc", line 113, in browseableMessage
  File "comtypes\client\__init__.pyc", line 264, in CreateObject
  File "comtypes\client\__init__.pyc", line 181, in _manage
  File "comtypes\client\__init__.pyc", line 115, in GetBestInterface
  File "comtypes\client\_generate.pyc", line 132, in GetModule
  File "comtypes\client\_generate.pyc", line 246, in _create_wrapper_module
  File "comtypes\client\_generate.pyc", line 181, in _create_module_in_file
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Cyrille\\AppData\\Local\\Temp\\comtypes_cache\\nvda-311\\_420B2830_E718_11CF_893D_00A0C9054228_0_1_0.py'
IO - speech.speech.speak (09:41:37.002) - MainThread (20472):
Speaking ["Impossible d'afficher le message navigable"]

Could not open any browseable message until I restart NVDA.

@LeonarddeR are you able to fix this?