Skip to content

Fix freeze when locking / unlocking user session in Windows#19065

Merged
seanbudd merged 2 commits into
masterfrom
i19037
Oct 8, 2025
Merged

Fix freeze when locking / unlocking user session in Windows#19065
seanbudd merged 2 commits into
masterfrom
i19037

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #19037

Summary of the issue:

After switching to 64 bit, when locking the user session with windows+l, or when cuming out of the lock screen, NVDA will freeze and become unusable. It was necessary to restart NVDA.

This was caused by NVDA going into an infinit loop when trying to detect if a given window was above or below the lock screen. A loop would be calling winUser.GetWindow, and breaking when the window equals GWL_NOT_FOUND (0). However, after switching to 64 bit, the value from winUser.getWindow when there was no window, was now None, not 0, so it never matched and the loop continued for ever.

winUser.getwindow internally calls user32's GetWindow, which with our new tightened winBindings ctypes definitions, was defined to return HWND, rather than just a default long. Problem is that ctypes always converts NULL pointers (including HWND) to None on return.

Description of user facing changes:

Description of developer facing changes:

Description of development approach:

for all functions in our high-level winUser module that return a window handle, ensure that 0 is returned instead of None if a null HWND is being returned. This keeps these high-level functions compatible with existing code, and therefore no longer breaks lock screen detection logic. Also add type hints for params and return for these particular functions.

Testing strategy:

  • General smoke test of an installed signed binary copy.
  • With an installed signed binary copy running: Lock with windows+l. Verify that object navigation works within the lock screen and cannot escape. Dismiss the lock screen and log back into Windows, and verify that NVDA is still functional.

Known issues with pull request:

None known.

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.

… return 0 for a NULL window handle like they always did before the tightening of ctypes definitions, rather than returning None, which was breaking some existing code such as lock screen detection.
Copilot AI review requested due to automatic review settings October 8, 2025 03:26
@michaelDCurran michaelDCurran requested a review from a team as a code owner October 8, 2025 03:26

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 PR fixes a critical freeze issue where NVDA becomes unresponsive when users lock/unlock their Windows session using Windows+L. The issue was caused by an infinite loop in window detection logic that occurred after migrating to 64-bit, where NULL HWND values are now returned as None instead of 0, breaking existing comparison logic.

  • Fixed high-level winUser functions to return 0 instead of None for NULL HWND values
  • Added type hints for parameters and return values to affected functions
  • Maintained backward compatibility with existing code that expects 0 for invalid window handles

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread source/winUser.py Outdated
@seanbudd seanbudd enabled auto-merge (squash) October 8, 2025 03:59
@seanbudd seanbudd merged commit dac72c1 into master Oct 8, 2025
29 checks passed
@seanbudd seanbudd deleted the i19037 branch October 8, 2025 04:02
@github-actions github-actions Bot added this to the 2026.1 milestone Oct 8, 2025
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.

Freeze when locking windows

3 participants