Focus changes in web browsers make many avoidable calls to the browser
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- accessibility, performance
Research direction
Start by reading NVDA's helpers that fetch and normalize IAccessible::accParent and accChild, and its comtypes monkey patches for QueryInterface and QueryService, as described in the issue. Reproduce the Tab-focus timing and trace the calls into the browser. Done means avoiding calls whose results are unused while preserving identical speech output and confirming the improvement with timing measurements.
Written by the indexing model from the issue text.
Description
Brief summary
Moving the focus in web content, for example pressing Tab between links and form fields, takes NVDA around 90 ms of its own time per keypress on my test machine. Tracing the COM calls NVDA makes shows about 106 cross-process calls into the browser per Tab, and a large share of the time goes to calls whose results NVDA doesn't use:
- When NVDA fetches
IAccessible::accParentoraccChildthrough comtypes, comtypes converts the returnedIDispatchto the "best" interface (comtypes.client._managing.GetBestInterface). This queries forIProvideClassInfoandIProvideClassInfo2(both fail in Chromium), callsIDispatch::GetTypeInfoand makes several calls on the returned type information. NVDA then normalizes the result toIAccessibleitself (IAccessibleHandler.normalizeIAccessible). In Edge, fetching a parent this way took 4 to 7 ms during a focus change, about 27 ms per Tab in total. - When any COM method fails, ctypes asks the object for error information, starting with
QueryInterface(ISupportErrorInfo). ForQueryInterfaceandQueryServicea failure is a normal answer and there's never error information, but for an out-of-process object the extra query is a second round trip. NVDA makes five queries that always fail in Chromium for eachIAccessibleNVDAObject it creates (IAccIdentity,IAccessibleTable2,IAccessibleTable, andQueryServiceforIHTMLElementandITextServices), so each object creation spent about 6.5 of its 11 ms on failed queries, half of that on the error information requests.
Steps to reproduce
- Open a web page with links and form fields in Microsoft Edge, Google Chrome or Mozilla Firefox.
- Press Tab repeatedly.
- Measure the time from the key press to speech starting, or trace the COM calls NVDA makes.
Actual behaviour
Measured on a Windows 11 virtual machine (4 vCPUs, 8 GB), NVDA running from source on master, Edge, a simple test page with 15 focusable elements, keys sent with SendInput at 0.6 second intervals, times from the key press to the first audible audio sent to WASAPI:
- Median about 113 ms per Tab with Eloquence (OpenEVV add-on), 108 ms with eSpeak NG.
- Edge reports the focus change within about 6 ms; almost all of the rest is NVDA's processing, most of it waiting on calls into the browser.
In a standalone script with Edge idle, fetching accParent as NVDA does and normalizing it took 3.7 ms, compared with 0.7 ms when calling the COM method directly and then normalizing. A failed QueryInterface took 0.71 ms, compared with 0.32 ms without the error information request.
Expected behaviour
NVDA shouldn't spend time on calls whose results it doesn't use.
NVDA logs, crash dumps and other attachments
I can attach the per-call trace and the standalone timing script.
NVDA type
Running from source.
NVDA version
master at 72601bf32.
Have you tried any other versions of NVDA?
Not measured, but the same code is in 2026.3 beta 2.
Windows version
Windows 11 IoT Enterprise LTSC 2024 (26100).
Name and version of other software in use when reproducing the issue
Microsoft Edge (current stable), Mozilla Firefox 157.
Other information about your system
Virtual machine without performance/efficiency cores. Cross-process calls are slower on this machine than on typical hardware, but the proportions should be similar.
Does the issue still occur after restarting your computer?
Yes. The timings are consistent across many runs over several days.
If NVDA add-ons are disabled, is your problem still occurring?
Yes. The eSpeak NG measurements were made with no add-ons.
Does the issue still occur after you run the System Accessibility Repair Tool (COM Registration Fixing Tool in older versions) in NVDA's tools menu?
Not tried, as the cause is in NVDA's own code, described above, rather than COM registration.
I have fixes
I have two small changes ready, which I'd propose as separate pull requests: calling accParent and accChild without comtypes' conversion in NVDA's own helpers, and replacing QueryInterface and QueryService in NVDA's comtypes monkey patches with versions that don't request error information. Together they reduced Tab in Edge from about 113 ms to 66 ms, and in Mozilla Firefox 157 from about 172 ms to 86 ms, on this machine, with identical speech output in automated comparisons in Edge, Firefox, Thunderbird and LibreOffice.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 842
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 56
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvaccess/nvda
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
needs-technical-investigation p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
nvaccess/nvda#21085 · 7 comments ·
Maintainers usually reply within 1 day
-
Braille Viewer draws two braille patterns wrongly (U+28CC, U+2873) because of glyph errors in FreeMono-FixedBraille.ttfMay be free again A pull request for this issue was closed without being merged. Openaudience/a11y-tester good first issue p4 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nvaccess/nvda#21022 · 3 comments ·
Maintainers usually reply within 1 day
-
api-breaking-change audience/nvda-dev p5 release/blocking release/blocking-beta triaged
Difficulty 2/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100