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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11312
Author: @carlos-zamora
Created: 9/23/2021
Status: Merged
Merged: 9/23/2021
Merged by: @carlos-zamora

Base: mainHead: dev/cazamor/a11y-initialize-hang


📝 Commits (3)

📊 Changes

10 files changed (+83 additions, -69 deletions)

View changed files

📝 src/Terminal.wprp (+2 -0)
📝 src/cascadia/TerminalCore/Terminal.hpp (+1 -0)
📝 src/cascadia/TerminalCore/terminalrenderdata.cpp (+9 -0)
📝 src/host/renderData.hpp (+1 -0)
📝 src/host/ut_host/VtIoTests.cpp (+5 -0)
📝 src/types/IUiaData.h (+1 -0)
📝 src/types/ScreenInfoUiaProviderBase.cpp (+11 -14)
📝 src/types/TermControlUiaProvider.cpp (+6 -8)
📝 src/types/TermControlUiaTextRange.cpp (+0 -14)
📝 src/types/UiaTextRangeBase.cpp (+47 -33)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11312 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 9/23/2021 **Status:** ✅ Merged **Merged:** 9/23/2021 **Merged by:** [@carlos-zamora](https://github.com/carlos-zamora) **Base:** `main` ← **Head:** `dev/cazamor/a11y-initialize-hang` --- ### 📝 Commits (3) - [`d7750f5`](https://github.com/microsoft/terminal/commit/d7750f5ca3f4861e8de6b2a2e14f1f6744209d5e) fix hang - [`047fe91`](https://github.com/microsoft/terminal/commit/047fe91cc5d5a8725f2d8b9c07c5b1e958883c5b) fix MockRenderData - [`dd2f704`](https://github.com/microsoft/terminal/commit/dd2f7046b26dbc2e687f578224bbce4d00c64861) consistently lock before checking if initialized ### 📊 Changes **10 files changed** (+83 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `src/Terminal.wprp` (+2 -0) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+1 -0) 📝 `src/cascadia/TerminalCore/terminalrenderdata.cpp` (+9 -0) 📝 `src/host/renderData.hpp` (+1 -0) 📝 `src/host/ut_host/VtIoTests.cpp` (+5 -0) 📝 `src/types/IUiaData.h` (+1 -0) 📝 `src/types/ScreenInfoUiaProviderBase.cpp` (+11 -14) 📝 `src/types/TermControlUiaProvider.cpp` (+6 -8) 📝 `src/types/TermControlUiaTextRange.cpp` (+0 -14) 📝 `src/types/UiaTextRangeBase.cpp` (+47 -33) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:28:55 +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#28496