Skip to content

Add debouncer#19702

Merged
seanbudd merged 21 commits into
betafrom
debouncer
Mar 5, 2026
Merged

Add debouncer#19702
seanbudd merged 21 commits into
betafrom
debouncer

Conversation

@seanbudd

@seanbudd seanbudd commented Feb 26, 2026

Copy link
Copy Markdown
Member

Link to issue number:

Inspired by #19686

Summary of the issue:

We regularly run into problems where the GUI being updated frequently causing issues.
We fix this using a ratelimiter/debouncer.
We do not have a generic debouncer in NVDA.

Description of user facing changes:

none

Description of developer facing changes:

Adds a generic debouncer to NVDA

Description of development approach:

This pull request introduces a new debouncing utility for limiting the frequency of function calls, primarily to improve GUI responsiveness and reduce unnecessary processing in NVDA. The main changes include the addition of the debounceLimiter decorator, its integration into the browseMode.py file for filtering elements, and comprehensive unit tests to verify its behavior. The pull request also modernizes type annotations throughout browseMode.py for improved readability and consistency.

Debounce utility and integration:

  • Added a new debounceLimiter decorator in utils/debounce.py to control the execution rate of functions, supporting both GUI and daemon threads.
  • Integrated debounceLimiter into the filtering logic of the elements list dialog in browseMode.py, replacing manual timer handling for improved efficiency and code clarity. [1] [2]

Testing

Introduced tests/unit/test_util/test_debounce.py with unit tests covering various debounce scenarios, including cooldown, delay, call coalescing, and per-instance limiting.

Manually tested filtering the elements list dialog

Known issues with pull request:

None

Code Review Checklist:

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

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Feb 26, 2026
@seanbudd seanbudd marked this pull request as ready for review February 26, 2026 06:30
@seanbudd seanbudd requested a review from a team as a code owner February 26, 2026 06:30
@seanbudd seanbudd marked this pull request as draft February 26, 2026 06:30
@seanbudd seanbudd changed the base branch from master to beta February 26, 2026 06:31
@seanbudd seanbudd added this to the 2026.1 milestone Feb 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a new debouncing utility to the NVDA codebase and applies it to the browse mode elements list filter functionality. The debouncer provides a reusable mechanism for rate-limiting function calls by executing the first call immediately and debouncing subsequent calls within a cooldown period.

Changes:

  • Added a new debounceLimiter decorator in source/utils/debounce.py that supports GUI and daemon thread targets
  • Replaced manual wx.CallLater timer management in browse mode's elements list filter with the new debouncer
  • Updated type hints in browseMode.py from Optional[X]/Union[X, Y] to modern PEP 604 syntax (X | None, X | Y)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
source/utils/debounce.py New utility module providing the debounceLimiter decorator for debouncing function calls with configurable cooldown and delay times, supporting both GUI and daemon thread execution
tests/unit/test_util/test_debounce.py Comprehensive unit tests for the debouncer covering immediate execution, coalescing, cooldown behavior, and per-instance state tracking
source/browseMode.py Refactored elements list filter to use the new debouncer, removed manual timer management, and modernized type hints throughout the file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/utils/debounce.py Outdated
Comment thread source/browseMode.py Outdated
Comment thread source/browseMode.py
Comment thread source/utils/debounce.py Outdated
Comment thread source/utils/debounce.py Outdated
@seanbudd seanbudd mentioned this pull request Feb 26, 2026
5 tasks
seanbudd and others added 4 commits February 26, 2026 17:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/utils/debounce.py
Comment thread source/utils/debounce.py Outdated
Comment thread tests/unit/test_util/test_debounce.py Outdated
Comment thread source/browseMode.py
Comment thread source/browseMode.py Outdated
@seanbudd seanbudd marked this pull request as ready for review February 27, 2026 05:29
Comment thread source/utils/debounce.py Outdated
Comment thread source/utils/debounce.py Outdated
Comment thread source/utils/debounce.py Outdated
Comment thread source/utils/debounce.py Outdated
Comment thread source/utils/debounce.py
Comment thread source/browseMode.py Outdated
Comment thread source/browseMode.py Outdated
Comment thread source/browseMode.py Outdated
Comment thread source/browseMode.py Outdated
Comment thread source/browseMode.py Outdated
@SaschaCowley SaschaCowley marked this pull request as draft March 3, 2026 02:46
@seanbudd seanbudd requested a review from SaschaCowley March 3, 2026 06:10
@seanbudd seanbudd marked this pull request as ready for review March 3, 2026 06:11
seanbudd and others added 2 commits March 3, 2026 17:54
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
@seanbudd seanbudd merged commit 704647b into beta Mar 5, 2026
39 checks passed
@seanbudd seanbudd deleted the debouncer branch March 5, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-breaking-change conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants