V2 of External win event limiter - #20653
Open
codeofdusk wants to merge 5 commits into
Open
Conversation
codeofdusk
force-pushed
the
externalWinEventLimiter
branch
3 times, most recently
from
August 13, 2026 13:34
89b8c5b to
bccf41e
Compare
codeofdusk
force-pushed
the
externalWinEventLimiter
branch
from
August 13, 2026 14:07
bccf41e to
be31555
Compare
codeofdusk
marked this pull request as ready for review
August 13, 2026 14:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Supersedes #10556.
Summary of the issue:
There is some suspicion that NVDA may be missing some events by not handling windows events callbacks fast enough. Not only this, but processing and queuing events takes up time on the main thread when it isn't necessary to do so.
Description of how this pull request fixes the issue:
This PR modernizes the external winEvent limiter first developed experimentally in 2019 by @feerrenrut. When enabled,
winEventLimiter.dllreceives, preprocesses and limits winEvents outside NVDA's main Python event loop. NVDA then fetches the surviving events in chronological order during its normal core pump.The external limiter is disabled by default. It can be enabled from the new "Microsoft Active Accessibility" group in the Advanced settings panel. If the DLL cannot be loaded or started, NVDA falls back to its existing internal winEvent hooks.
This PR also:
eventHandlertowinEventLimiter. This avoids a name collision with NVDA's PythoneventHandlermodule;pumpAlltry the newest valid focus candidate without producing reverse-order focus speech;MAX_BUFFERED_EVENTS. On overflow, queues are trimmed toward half capacity, discarding older generic events first and preferentially retaining focus, foreground, destroy, and focused-object events;EVENT_OBJECT_REORDERevents from reachingpumpAll;winEventLimiter_setAlwaysAllowedObject(Don't filter out MSAA events for the currently focused object, even if the winEvent limit has been exceeded for that thread #11520);ConsoleWindowClasswindows and exposes it throughwinEventLimiter_getConsoleThreadIDfor both console NVDAObject implementations (Speak typed characters in Windows consoles in the correct language (second try) #10554);EXCEL7winEvents (Ignore redundant winEvents proxied from UIA on EXCEL7 windows #11818);Testing strategy:
Manually tested for several weeks in a running copy of NVDA, including Chrome, Edgium, Firefox, and various MSAA applications. The external limiter is behind a feature flag and has no impact on the running NVDA when disabled (default behaviour) to allow for wider testing.
Automated testing:
runcxxtests.bat: event ordering and limiting, focus handling, duplicate and show/hide semantics, notifications, buffer overflow, destroy-event recovery and current pipeline parity.cxxUnitTestsCI job runs the native tests.rununittests.bat -k test_externalWinEventLimiter: event fetching and injection, main-thread destroy processing, fallback behaviour, lifecycle handling, console thread lookup, focus ordering, and feature-flag handling.Known issues with pull request:
None known.
Code Review Checklist: