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

With no braille display connected, exception is thrown inside a MathCAT braille computation #17563

Closed
NSoiffer opened this issue Dec 20, 2024 · 5 comments
Milestone

Comments

@NSoiffer
Copy link
Contributor

This is a new bug that has shown up in NVDA 2025.1 alpha code. It is not part of 2024.4 or prior releases. Nothing changed in MathCAT.

If I turn on the braille viewer, there is no problem. This is possibly related to this commit which seems to try to address a similar "integer division or modulo by zero" error.

I can probably work around this bug by making a change in MathCAT to detect whether a braille display is connected or not. That's useful to do for efficiency (why generate braille when it goes nowhere?), but I suspect that other addons might be affected also so this would be good to fix.

FYI: I traced the exception to the call to self._calculateWindowRowBufferOffset in source/braille.py:BrailleBuffer::update(). However, I can't see where there is division by 0 or modulo being called in that method.

Steps to reproduce:

  1. Install MathCAT addon
  2. Turn off any braille displays
  3. Unzip and open test.html in a browser. (Due to a bug with chromium, you made need to open in Firefox for math to read).
  4. Navigate to the math expression and hit "enter" to begin math navigation. You will hear an error message.

Actual behavior:

The speech log is:

     t        raised to the fraction         b         plus  1         over 3         end fraction         power       
math
   in base         t      
Error in brailling math: see NVDA error log for details

and the log file contains the line:

ERROR - external:globalPlugins.MathCAT.MathCAT.MathCATInteraction.script_navigate (13:18:58.696) - MainThread (13688):
integer division or modulo by zero

Expected behavior:

There should be no error.

NVDA logs, crash dumps and other attachments:

System configuration

NVDA installed/portable/running from source:

Running from source

NVDA version:

2025.1 current source

Windows version:

Windows 10

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

Other information about your system:

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.

All previous versions of NVDA have worked

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

NA

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

Yes

@Adriani90
Copy link
Collaborator

Cc: @Emil-18, @LeonarddeR

@NSoiffer
Copy link
Contributor Author

Related to my plans to a work around: is there a public interface that says whether a braille display is connected? I thought config.conf["braille"]["display"] would tell me useful info, but it has the value auto even when there is no display.

@nvdaes
Copy link
Collaborator

nvdaes commented Dec 21, 2024

@NSoiffer , here Noelia. I'm not sure if you receive my private emails or they are missing.
I've fixed this locally in MathCat add-on with this before try in the nav script:

if not braille.handler.enabled:
return

I'm not sure if this requires some kind of fix in NVDA, or if this is some to be fixed in MathCat or other add-ons if they override NVDA's behavior to show text in braille.
Hope this helps.

@NSoiffer
Copy link
Contributor Author

@nvdaes: thanks, that's the check I was looking for for the workaround.

That solves the problem for MathCAT, but addons may run into the same problem.

NSoiffer added a commit to NSoiffer/MathCATForPython that referenced this issue Dec 21, 2024
It is also a minor speedup in that it no longer computes the braille string when there is no braille display.
@LeonarddeR
Copy link
Collaborator

Hi @NSoiffer NSoiffer, thanks for reporting this.
I investigated your add-on. Here is wath I found.

  1. You use log.error(e) when catching an exception. This will only log the message of the exception to the log and will discard the exception info itself. I would personally use log.exception() instead. That will automatically log the exception info of the most recent exception and will make it easier to debug.
  2. You should indeed check braille.handler.enabled before doing anythin Braille related.

I'm closing this issue for now, since you have fixed your add-on and I currently see no reason why NVDA is in error here.

@github-actions github-actions bot added this to the 2025.1 milestone Dec 21, 2024
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

No branches or pull requests

4 participants