[PR #11312] [a11y] Ensure buffer is initialized before interacting with it #28501

Open
opened 2026-01-31 09:28:57 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/11312

State: closed
Merged: Yes


Summary of the Pull Request

Adds a check before every UIA function call to ensure the terminal (specifically the buffer) is initialized before doing work. Both the ScreenInfoUiaProvider and the UiaTextRange are now covered.

References

Closes #11135
#10971 & #11042

Detailed Description of the Pull Request / Additional comments

Originally, I tried applying this heuristic to all the RuntimeClassInitialize on UiaTextRangeBase with the philosophy of "a range pointing to an invalid buffer is invalid itself", but that caused a regression on MSFT 33353327.

IUiaData also has GetTextBuffer() return a TextBuffer&, which cannot be checked for nullness. Instead, I decided to add a function to IUiaData that checks if we have a valid state. Since this is shared with Conhost and Conhost doesn't have this issue, I simply make that function say that it's always in a valid state.

Validation Steps Performed

  • Narrator can detect newly created terminals
  • (On Windows Server 2022) Windows Terminal does not hang on launch
**Original Pull Request:** https://github.com/microsoft/terminal/pull/11312 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Adds a check before every UIA function call to ensure the terminal (specifically the buffer) is initialized before doing work. Both the `ScreenInfoUiaProvider` and the `UiaTextRange` are now covered. ## References Closes #11135 #10971 & #11042 ## Detailed Description of the Pull Request / Additional comments Originally, I tried applying this heuristic to all the `RuntimeClassInitialize` on `UiaTextRangeBase` with the philosophy of "a range pointing to an invalid buffer is invalid itself", but that caused a regression on [MSFT 33353327](https://microsoft.visualstudio.com/OS/_workitems/edit/33353327). `IUiaData` also has `GetTextBuffer()` return a `TextBuffer&`, which cannot be checked for nullness. Instead, I decided to add a function to `IUiaData` that checks if we have a valid state. Since this is shared with Conhost and Conhost doesn't have this issue, I simply make that function say that it's always in a valid state. ## Validation Steps Performed - [X] Narrator can detect newly created terminals - [X] (On Windows Server 2022) Windows Terminal does not hang on launch
claunia added the pull-request label 2026-01-31 09:28:57 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28501