Skip to content
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

Persistent 'Error checking if obj in buffer' in Firefox #48

Open
AAClause opened this issue Aug 12, 2024 · 3 comments
Open

Persistent 'Error checking if obj in buffer' in Firefox #48

AAClause opened this issue Aug 12, 2024 · 3 comments
Labels

Comments

@AAClause
Copy link
Member

AAClause commented Aug 12, 2024

Since NVDA version alpha-32590,9afb6fc5 (June 27), with WebAccess enabled, the following error is continuously logged in Firefox specifically while using any keyboard-based navigation (such as Tab or arrow keys) within web page content in Firefox:

Error checking if obj in buffer
Traceback (most recent call last):
  File "virtualBuffers\gecko_ia2.pyc", line 287, in __contains__
  File "comtypes\_memberspec.pyc", line 482, in __call__
_ctypes.COMError: (-2147417842, 'The application called an interface that was marshalled for a different thread.', (None, None, None, 0, None))

Related to nvaccess/nvda#16746

Affected stable versions: 2024.2 and 2024.3.

@AAClause
Copy link
Member Author

The issue appears to be linked to the following line within the WebAccess codebase:

if obj.parent and obj.parent.treeInterceptor:

This line triggers the function virtualBuffers.gecko_ia2.Gecko_ia2.__contains__. The main point of failure within this function seems to be self.rootNVDAObject.IAccessibleObject.accChild(accId), which leads to the _ctypes.COMError.

@JulienCochuyt Any idea to solve this, knowing that catching the COMError exception is not a viable option?

@AAClause AAClause added the bug label Aug 22, 2024
@AAClause
Copy link
Member Author

As a temporary solution, I apply a monkey patch to the gecko_ia2.Gecko_ia2.__contains__ method by adding the following condition in the exception block (I assume this isn't the correct approach):

			if e.hresult == -2147417842:
				# The application called an interface that was marshalled for a different thread.
				return False

I'm unsure whether this requires a fix in the NVDA core or if there are errors in the WebAccess calls. However, we do not encounter these issues with Chromium-based browsers, and there was no such problem in Firefox prior to the changes in nvaccess/nvda#16746.

@jcsteh Your expertise would be greatly appreciated. :)

@jcsteh
Copy link

jcsteh commented Sep 1, 2024

This indicates that you're querying buffers from a thread other than the main thread, which you should not do. The only reason this doesn't impact Chromium is that the Chromium vbuf catches all COM errors and ignores them, whereas the updated code for Firefox explicitly checks for E_INVALIDARG, which indicates that the object is not in the buffer. To put this another way, the problem does exist for Chromium; it's just being silently swallowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants