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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/host/srvinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ try
}
}

if (args->InConptyMode())
{
// 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?

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.

}

// Removed allocation of scroll buffer here.
return S_OK;
}
Expand Down
18 changes: 18 additions & 0 deletions src/interactivity/base/ServiceLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ void ServiceLocator::RundownAndExit(const HRESULT hr)

#pragma region Set Methods

[[nodiscard]] NTSTATUS ServiceLocator::SetAccessibilityNotifier(_In_ std::unique_ptr<IAccessibilityNotifier>&& notifier)
{
if (s_accessibilityNotifier)
{
NT_RETURN_NTSTATUS(STATUS_INVALID_HANDLE);
}
else if (!notifier)
{
NT_RETURN_NTSTATUS(STATUS_INVALID_PARAMETER);
}
else
{
s_accessibilityNotifier = std::move(notifier);
}

return STATUS_SUCCESS;
}

[[nodiscard]] NTSTATUS ServiceLocator::SetConsoleControlInstance(_In_ std::unique_ptr<IConsoleControl>&& control)
{
if (s_consoleControl)
Expand Down
15 changes: 15 additions & 0 deletions src/interactivity/inc/IAccessibilityNotifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,19 @@ namespace Microsoft::Console::Interactivity
};

inline IAccessibilityNotifier::~IAccessibilityNotifier() {}

class NoOpAccessibilityNotifier final : public IAccessibilityNotifier
{
public:
NoOpAccessibilityNotifier() = default;
~NoOpAccessibilityNotifier() = default;
void NotifyConsoleCaretEvent(_In_ RECT /*rectangle*/) override{};
void NotifyConsoleCaretEvent(_In_ ConsoleCaretEventFlags /*flags*/, _In_ LONG /*position*/) override{};
void NotifyConsoleUpdateScrollEvent(_In_ LONG /*x*/, _In_ LONG /*y*/) override{};
void NotifyConsoleUpdateSimpleEvent(_In_ LONG /*start*/, _In_ LONG /*charAndAttribute*/) override{};
void NotifyConsoleUpdateRegionEvent(_In_ LONG /*startXY*/, _In_ LONG /*endXY*/) override{};
void NotifyConsoleLayoutEvent() override{};
void NotifyConsoleStartApplicationEvent(_In_ DWORD /*processId*/) override{};
void NotifyConsoleEndApplicationEvent(_In_ DWORD /*processId*/) override{};
};
}
1 change: 1 addition & 0 deletions src/interactivity/inc/ServiceLocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Microsoft::Console::Interactivity
// In case the on-demand creation fails, the return value
// is nullptr and a message is logged.

[[nodiscard]] static NTSTATUS SetAccessibilityNotifier(_In_ std::unique_ptr<IAccessibilityNotifier>&& notifier);
static IAccessibilityNotifier* LocateAccessibilityNotifier();

[[nodiscard]] static NTSTATUS SetConsoleControlInstance(_In_ std::unique_ptr<IConsoleControl>&& control);
Expand Down