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

Skip accessibility notifier and all event calculations when we're in PTY mode #10569

Merged
3 commits merged into from
Jul 9, 2021

Conversation

miniksa
Copy link
Member

@miniksa miniksa commented Jul 6, 2021

Change accessibility notifier creation so we do not create one when we're in PTY mode. (Guard all call sites to skip math/event work when the notifier is null.) MSAA events are legacy events that are registered for globally and used by some screen readers to find content in the conhost window. The PTY mode is not responsible for hosting the display content or input window, so it makes sense for it to not broadcast these events and delegate the accessibility requirement to the connected terminal.

References

PR Checklist

@ghost ghost added Area-Accessibility Issues related to accessibility Area-Performance Performance-related issue Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conpty For console issues specifically related to conpty labels Jul 6, 2021
@miniksa
Copy link
Member Author

miniksa commented Jul 6, 2021

cc: @skyline75489

Copy link
Collaborator

@skyline75489 skyline75489 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comments about why this is needed :)

src/interactivity/base/ServiceLocator.cpp Outdated Show resolved Hide resolved
{
// If we're in ConPTY mode... set the no-op accessibility notifier
// to prevent sending expensive legacy MSAA events when we won't even be
// responsible for the terminal user interface.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to audit the places where IAccessibilityNotifier is used, in addition to having the no-op interface.

I say this because ... the one that notifies about buffer changes reads the buffer first, before calling out to IAN. It's a waste of time if IAN is a no-op, which still increases our output time burden.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh, you've got a good point about SCREEN_INFORMATION::NotifyAccessibilityEventing. If we're really trying to be as optimal as possible, then yea we shouldn't do that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why SCREEN_INFORMATION::NotifyAccessibilityEventing is the only thing showed up in the WPR trace. Maybe this indicates that other places that calls IAccessibilityNotifier are not as expensive?

// to prevent sending expensive legacy MSAA events when we won't even be
// responsible for the terminal user interface.
std::unique_ptr<IAccessibilityNotifier> noOpNotifier = std::make_unique<Microsoft::Console::Interactivity::NoOpAccessibilityNotifier>();
RETURN_IF_NTSTATUS_FAILED(ServiceLocator::SetAccessibilityNotifier(std::move(noOpNotifier)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this doesn't cause us to blow up later... because isn't somebody else going to set it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it creates it if it was not already created. Clever.

@miniksa
Copy link
Member Author

miniksa commented Jul 8, 2021

Alternative strategy proposal....

Instead of adding a no-op renderer... I'll change it so

  • all call sites will check if the notifier is null before calling it (or doing any extra work that would be required to call it)
  • startup explicitly creates an appropriate (win32 or onecore or none for PTY) notifier instead of the implicit create-on-first-use behavior
  • I'll undo the check is-in-PTY-mode inside the SCREEN_INFORMATION::NotifyAccessibilityEventing as it will no longer be needed and would be a waste of time.

Sound OK?

@DHowett
Copy link
Member

DHowett commented Jul 8, 2021

S_OK for me

…all callsites and avoid parameter math if it's null to save more time.
@miniksa miniksa requested a review from lhecker July 8, 2021 22:26
@miniksa miniksa changed the title Add no-op accessibility notifier when we're in PTY mode Skip accessibility notifier and all event calculations when we're in PTY mode Jul 8, 2021
@miniksa
Copy link
Member Author

miniksa commented Jul 8, 2021

Cleared @lhecker approval for plan B.

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like.

src/interactivity/base/ServiceLocator.cpp Outdated Show resolved Hide resolved
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only going to have nits, but I think I had enough of them as to start asking questions. 😄

Comment on lines -560 to +563
screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, CursorPosition.X + gsl::narrow<SHORT>(i - 1), CursorPosition.Y);
if (screenInfo.HasAccessibilityEventing())
{
screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, CursorPosition.X + gsl::narrow<SHORT>(i - 1), CursorPosition.Y);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it (consistency!), but this also seems like a decision SCREEN_INFO can make for itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid the math on the 3rd param too... and below...
That and the consistency argument together are what made me guard it.

Comment on lines +379 to +382
if (screenInfo.HasAccessibilityEventing())
{
screenInfo.NotifyAccessibilityEventing(insertionPos.X, insertionPos.Y, gsl::narrow<SHORT>(insertionPos.X + lineVec.size() - 1), insertionPos.Y);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ut supra

src/host/screenInfo.cpp Show resolved Hide resolved
src/host/srvinit.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 9, 2021
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 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.

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.

@ghost ghost merged commit 91b454a into main Jul 9, 2021
@ghost ghost deleted the dev/miniksa/acc_nooop branch July 9, 2021 18:45
DHowett pushed a commit that referenced this pull request Jul 12, 2021
…PTY mode (#10569)

Change accessibility notifier creation so we do not create one when we're in PTY mode. (Guard all call sites to skip math/event work when the notifier is null.) MSAA events are legacy events that are registered for globally and used by some screen readers to find content in the conhost window. The PTY mode is not responsible for hosting the display content or input window, so it makes sense for it to not broadcast these events and delegate the accessibility requirement to the connected terminal.

## References
- #10537

## PR Checklist
* [x] Closes #10568
* [x] I work here
* [x] Manual test launches passed.

(cherry picked from commit 91b454a)
@ghost
Copy link

ghost commented Jul 14, 2021

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

Handy links:

@ghost
Copy link

ghost commented Jul 14, 2021

🎉Windows Terminal Preview v1.10.1933.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 Area-Performance Performance-related issue AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make no-op IAccessibilityNotifier for ConPTY mode
5 participants