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

Fix math not being read in Chromium-based browsers (#17421) #17548

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

NSoiffer
Copy link
Contributor

@NSoiffer NSoiffer commented Dec 18, 2024

Note:: this is the same as #17528 but done on a non-master branch in my fork. According to @seanbudd, permissions to push in the fork don't work properly when coming from master, so here's a second attempt in case it makes life easier.

Fix math not being read in Chromium-based browsers. Chromium made a change that causes a call to (correctly) return E_NOTIMPL.

This simple fix catches the exception and moves on. The NVDA behavior should be the same as before the Chromium change. Only E_NOTIMPL is caught, other COMErrors are re-raised.

Fixes #17421.

This fixes a very serious user-issue. I recommend that a 2024.4.2 build happen with this fix if possible.

Link to issue number:

Fixes #17421

Summary of the issue:

Chromium-browsers were changed to return E_NOTIMPL and broke speech and braille of all math equations (i.e., no speech or braille for math) in those browsers because NVDA passes along a 'not implemented' COM exception.

Description of user facing changes

This restores the behavior of NVDA (i.e., math reads) as before the change.

Description of development approach

A try/except block is added around the call. If the error is E_NOTIMPL, the code moves on as before. Otherwise, the error is re-raised as before.

Testing strategy:

Make sure that some math addon is present. I tested with MathCAT, but any math addon will do. Go to any page with math (e.g., https://en.wikipedia.org/wiki/Quadratic_equation). Navigate to a math expression. Without the change, you will not hear any math. With the change, you will hear the math expression being read.

Known issues with pull request:

None.

Code Review Checklist:

I did not make a change log entry because I don't know what version this change will go into. I think a simple entry like

Restore reading of math in Chromium-based browsers (Chrome/Edge/...) by handling a change they made.

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

Summary by CodeRabbit

  • New Features

    • Support for new braille displays and input methods, including contracted braille input.
    • Automatic language switching for documents with language information.
    • Enhanced support for Microsoft Office applications, including formatting and math content reporting.
    • Improved web browsing support with faster content rendering and ARIA landmark support.
    • Introduction of a new Add-on Manager for managing NVDA add-ons.
    • Experimental support for touch screen interactions.
  • Bug Fixes

    • Various bug fixes and stability improvements.

NSoiffer and others added 2 commits December 16, 2024 21:24
…ange that causes a call to (correctly) return E_NOTIMPL.

This simple fix catches the exception and moves on. The behavior should be the same as before the Chromium change. Only E_NOTIMPL is caught, other COMErrors are re-raised.

Fixes nvaccess#17421
@NSoiffer NSoiffer requested a review from a team as a code owner December 18, 2024 07:24
@NSoiffer NSoiffer requested a review from seanbudd December 18, 2024 07:24
@seanbudd seanbudd changed the base branch from master to rc December 19, 2024 01:33
@seanbudd seanbudd requested a review from a team as a code owner December 19, 2024 01:33
user_docs/en/changes.md Outdated Show resolved Hide resolved
Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

Walkthrough

The pull request introduces an enhancement to error handling in the Math class within the ia2Web.py file. Specifically, it modifies the _get_mathMl method to handle scenarios where the attributesForNames method is not implemented. The change involves adding a try-except block to catch COMError and specifically handle the E_NOTIMPL error case by setting the attribute to None while logging a warning for other types of errors.

Changes

File Change Summary
source/NVDAObjects/IAccessible/ia2Web.py Added import for E_NOTIMPL and enhanced error handling in _get_mathMl method

Assessment against linked issues

Objective Addressed Explanation
Navigate math content in Chromium [#17421] Partial improvement in error handling, but full resolution requires further investigation

Possibly related PRs

Suggested labels

conceptApproved

Suggested reviewers

  • LeonarddeR
  • SaschaCowley

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NSoiffer thanks, I've force pushed the commit f866ffc which is based off rc not master

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
source/NVDAObjects/IAccessible/ia2Web.py (2)

338-344: LGTM: Error handling implementation addresses the Chromium issue.

The implementation correctly handles the E_NOTIMPL error while preserving other error cases, which solves the math reading issue in Chromium-based browsers.

Consider adding debug logging for the E_NOTIMPL case for consistency:

 try:
     attr = node.attributesForNames(1, attrNames, namespaceIds)
 except COMError as e:
     if e.hresult != E_NOTIMPL:
         log.debugWarning(f"MathML getting attr error: {e}")
         raise
+    log.debug("MathML attributesForNames not implemented, falling back to default behavior")
     attr = None

338-344: Add explanatory comment for future maintainers.

Consider adding a comment explaining why E_NOTIMPL is specifically handled, referencing the Chromium change that necessitated this fix.

+# Handle case where Chromium-based browsers return E_NOTIMPL for attributesForNames
+# This was introduced in Chromium version X and affects math content reading
 try:
     attr = node.attributesForNames(1, attrNames, namespaceIds)
user_docs/en/changes.md (2)

5-6: Improve clarity of patch release description

The description should be more specific about what is being fixed. Consider:

-This is a patch release to fix bugs with braille devices and reading math in Chromium.
+This is a patch release to fix bugs with braille devices and to fix math content not being read in Chromium-based browsers.

9-9: Fix formatting of bug fix entry

The bullet point for the math fix should be more descriptive and consistent with other entries:

-* Fixed bug with with reading math in Chromium Browsers (Chrome, Edge). (#17421, @NSoiffer)
+* Fixed an issue where math content was not being read in Chromium-based browsers (Chrome, Edge). (#17421, @NSoiffer)
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8ebe86 and f082b31.

📒 Files selected for processing (2)
  • source/NVDAObjects/IAccessible/ia2Web.py (2 hunks)
  • user_docs/en/changes.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
source/NVDAObjects/IAccessible/ia2Web.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

user_docs/en/changes.md (3)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.md: Focus on grammar, spelling, and punctuation. Also consider readability and clarity of contents. Ensure that changes follow the style of one sentence per line, suggest changes if this is not met.


Pattern user_docs/en/changes.md: Ensure each change log entry references an issue or pull request number. Change log entries can also include a reference to a GitHub author. Examples of valid change log entries: * Item with sub-items (#123, @username): * sub-item * bar (#342) * Item with. Multiple lines. (#143)

🔇 Additional comments (1)
source/NVDAObjects/IAccessible/ia2Web.py (1)

15-15: LGTM: Import added for new error handling.

The addition of E_NOTIMPL import is appropriate for the new error handling in the Math class.

@seanbudd seanbudd added this to the 2024.4.2 milestone Dec 19, 2024
@seanbudd seanbudd merged commit 9390788 into nvaccess:rc Dec 19, 2024
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2024
@NSoiffer
Copy link
Contributor Author

@seanbudd: thanks for doing that. For some reason, I always end up having trouble with forks. Sorry for all the bother.

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 cannot navigate math content in Chromium
2 participants