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

Prevent deadlock in UIA Move API #10937

Merged
2 commits merged into from
Aug 13, 2021
Merged

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Aug 12, 2021

Fixes a bug where interacting with Windows Terminal when using Narrator causes Windows Terminal to hang.

UiaTextRangeBase::Move() locks, but later calls UiaTextRangeBase::ExpandToEnclosingUnit() which attempts to lock again. The workaround for this is to introduce a _expandToEnclosingUnit() that does not lock the console. Then, Move() calls this new method, thus only allowing one lock to be established at a time.

This bug is observed to be in v1.11.2221.0 and not in v1.9.1942.0.

@carlos-zamora carlos-zamora added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Accessibility Issues related to accessibility Severity-Crash Crashes are real bad news. Product-Terminal The new Windows Terminal. zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. labels Aug 12, 2021
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/a11y/bugfix-prevent-deadlock branch from ef7db73 to fe32c70 Compare August 12, 2021 22:13
@microsoft microsoft deleted a comment from github-actions bot Aug 12, 2021
@DHowett
Copy link
Member

DHowett commented Aug 12, 2021

ide-effect of #10653, which prevents re-entry (the ability to lock multiple times on the same thread).

nit: the lock we were using BEFORE 10653 was ALSO not re-entrant. Don't blame it if it didn't cause it! 😄

@carlos-zamora
Copy link
Member Author

ide-effect of #10653, which prevents re-entry (the ability to lock multiple times on the same thread).

nit: the lock we were using BEFORE 10653 was ALSO not re-entrant. Don't blame it if it didn't cause it! 😄

🤷 my bad. Updating the comment.

@DHowett DHowett added zStable-Service-Queued-1.12 A floating label that tracks the current Stable version for servicing purposes. AutoMerge Marked for automatic merge by the bot when requirements are met labels Aug 12, 2021
@ghost
Copy link

ghost commented Aug 12, 2021

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 7 hours 53 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@DHowett
Copy link
Member

DHowett commented Aug 12, 2021

@msftbot merge this in 1

@ghost
Copy link

ghost commented Aug 12, 2021

Hello @DHowett!

I think you told me that you want to delay the approval for a certain amount of time, but I am not confident that I have understood you correctly.

Please try rephrasing your instruction to me.

@DHowett
Copy link
Member

DHowett commented Aug 12, 2021

@msftbot merge this in 1 year

@ghost
Copy link

ghost commented Aug 12, 2021

Hello @DHowett!

I think you told me that you want to delay the approval for a certain amount of time, but I am not confident that I have understood you correctly.

Please try rephrasing your instruction to me.

@DHowett
Copy link
Member

DHowett commented Aug 12, 2021

@msftbot merge this in 1 minute

@ghost
Copy link

ghost commented Aug 12, 2021

Hello @DHowett!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Thu, 12 Aug 2021 22:20:43 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit 0220f71 into main Aug 13, 2021
@ghost ghost deleted the dev/cazamor/a11y/bugfix-prevent-deadlock branch August 13, 2021 17:56
ghost pushed a commit that referenced this pull request Aug 18, 2021
…on (#10971)

## Summary of the Pull Request
The bug was that Narrator would still read the content of the old tab/pane although a new tab/pane was introduced. This is caused by the automation peer not being created when XAML requests it. Normally, we would prevent the automation peer from being created if the terminal was not fully initialized.

This change allows the automation peer to be created regardless of the terminal being fully initialized by...
- `TermControl`: `_InitializeTerminal` updates the padding (dependent on the `SwapChainPanel`) upon full initialization
- `ControlCore`: initialize the `_renderer` in the ctor so that we can attach the UIA Engine before `ControlCore::Initialize()` is called (dependent on `SwapChainPanel` loading)

As a bonus, this also fixes a locking issue where logging would attempt to get the text range's text and lock twice. The locking fix is very similar to #10937.

## PR Checklist
Closes [MSFT 33353327](https://microsoft.visualstudio.com/OS/_workitems/edit/33353327)

## Validation Steps Performed
- New pane from key binding is announced by Narrator
- New tab from key binding is announced by Narrator
DHowett pushed a commit that referenced this pull request Aug 25, 2021
Fixes a bug where interacting with Windows Terminal when using Narrator causes Windows Terminal to hang.

`UiaTextRangeBase::Move()` locks, but later calls `UiaTextRangeBase::ExpandToEnclosingUnit()` which attempts to lock again. The workaround for this is to introduce a `_expandToEnclosingUnit()` that _does not_ lock the console. Then, `Move()` calls this new method, thus only allowing one lock to be established at a time.

This bug is observed to be in v1.11.2221.0 and _not_ in v1.9.1942.0.
@DHowett DHowett removed the zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. label Aug 25, 2021
DHowett pushed a commit that referenced this pull request Aug 26, 2021
## Summary of the Pull Request
This patch accomplishes what #10971 does, but for the release-1.10 branch. Some things couldn't be carried over because the TermControl split wasn't the complete (or in the same state as it is currently on main).

The bug was that Narrator would still read the content of the old tab/pane although a new tab/pane was introduced. This is caused by the automation peer not being created when XAML requests it. Normally, we would prevent the automation peer from being created if the terminal was not fully initialized.

This change allows the automation peer to be created regardless of the terminal being fully initialized by...
- `ControlCore`: initialize the `_renderer` in the ctor so that we can attach the UIA Engine before `ControlCore::Initialize()` is called (dependent on `SwapChainPanel` loading)

As a bonus, this also fixes a locking issue where logging would attempt to get the text range's text and lock twice. The locking fix is very similar to #10937.

## Differences from #10971 
This was prior to #10874. _Thankfully_, we don't need to worry about the padding because that bug was introduced as a part of #10051.

## Other references
MSFT-33353327

## Validation Steps Performed
- New pane from key binding is announced by Narrator
- New tab from key binding is announced by Narrator
- Bounding rects are placed on the screen accurately (even when the padding changes)
@DHowett DHowett removed the zStable-Service-Queued-1.12 A floating label that tracks the current Stable version for servicing purposes. label Aug 27, 2021
@ghost
Copy link

ghost commented Aug 31, 2021

🎉Windows Terminal Preview v1.10.2383.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Aug 31, 2021

🎉Windows Terminal Preview v1.11.2421.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Accessibility Issues related to accessibility AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants