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

Use a single APC and completion routine #14924

Merged
merged 12 commits into from
Jun 2, 2023

Conversation

LeonarddeR
Copy link
Collaborator

@LeonarddeR LeonarddeR commented May 12, 2023

Link to issue number:

Related to #14899, #14312, #14627
Fixes #14895

Summary of the issue:

Despite several attempts to fix this, NVDA's IoThread can crash without a clear cause.

Description of user facing changes

Less crashes, most likely, as tests indicate that this is the case.

Description of development approach

As proposed by @jcsteh , rather than creating a new function pointer for every APC or completion routine call, use a single internal APC and completion routine and use an internal cache to store the python functions, not the actual APC functions.

Testing strategy:

Steps to reproduce from #14895.

Known issues with pull request:

None known

Change log entries:

Deprecations:

  • IoThread.autoDeleteApcReference is deprecated. It was introduced in NVDA 2023.1 and was never meant to be part of the public API. Until deprecation, it behaves as a no-op, i.e. a context manager yielding nothing.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

source/hwIo/ioThread.py Show resolved Hide resolved
source/hwIo/ioThread.py Outdated Show resolved Hide resolved
@AppVeyorBot

This comment was marked as resolved.

@LeonarddeR

This comment was marked as resolved.

@seanbudd

This comment was marked as resolved.

@LeonarddeR
Copy link
Collaborator Author

@MarcoZehe Could you please give this try build a spin?

@MarcoZehe
Copy link
Contributor

@LeonarddeR Obtained it and am currently running it off the installer, without installing it first. Should that be enough, or does it need elevated privileges somewhere to test this properly?

@LeonarddeR
Copy link
Collaborator Author

I don't think elevated privileges are necessary for your test case.

@LeonarddeR
Copy link
Collaborator Author

I used this build without crashes today. Let's mark it ready for review.

@LeonarddeR LeonarddeR marked this pull request as ready for review May 16, 2023 15:01
@LeonarddeR LeonarddeR requested a review from a team as a code owner May 16, 2023 15:01
@angeloabrantes

This comment was marked as off-topic.

@MarcoZehe
Copy link
Contributor

FWIW, I can definitely also confirm that this PR fixes the problem. With a regular alpha build, and working in Firefox or Thunderbird, especially in text fields, I get these crashes several times per day, sometimes even several per hour. With the try build, none of those. This definitely takes care of the issue I was having.

@ruifontes
Copy link
Contributor

Also agree!
Using Windows 11 22h2, a HT Basic Braille Plus.

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.

Thanks @LeonarddeR , the approach generally looks good to me, I have some concerns in regards to API backwards compatibility.

source/hwIo/ioThread.py Show resolved Hide resolved
source/hwIo/ioThread.py Show resolved Hide resolved
source/hwIo/ioThread.py Outdated Show resolved Hide resolved
@seanbudd seanbudd merged commit 4b18a9c into nvaccess:master Jun 2, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Jun 2, 2023
LeonarddeR added a commit to LeonarddeR/nvda that referenced this pull request Jul 29, 2023
seanbudd pushed a commit that referenced this pull request Jul 30, 2023
Fixup of #14924

Summary of the issue:
In #14627, we introduced weak references for APCs called as part of a waitable timer. In #14924, this was made more robust by using a single internal APC func. However in the porting process, a part of the logic was reversed, therefore in the internal APC store, we still stored strong rather than weak references.

Description of user facing changes
None.

Description of development approach
Store references instead of functions in the apc store.
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.

Error in hardware support with some events in Thunderbird and other places
8 participants