-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
wpf: delay-load UIAutomationCore because it's incomplete in RS1 #15614
Conversation
UiaRaiseNotificationEvent is not present on Windows Server 2016, even though it is documented as being present. This also removes the cost of loading up UIAutomationCore from the critical path.
Note it no longer shows up in the import list!
|
This comment has been minimized.
This comment has been minimized.
@@ -123,6 +133,12 @@ void HwndTerminalAutomationPeer::SignalCursorChanged() | |||
|
|||
void HwndTerminalAutomationPeer::NotifyNewOutput(std::wstring_view newOutput) | |||
{ | |||
if (_notificationsUnavailable) [[unlikely]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're checking _notificationsUnavailable
here but the first time we actually (might) set it is in _tryNotify
which is called later in this function. That means the first time we enter this function we are always doing the same thing as before, and only on future calls do we potentially skip attempting to notify. Is it possible for us to set the proper value for _notificationsUnavailable
for the first call as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we are "late-binding" the failure state. We want to act as though everything works on all platforms, and only when it fails (on Windows 8.1 or RS1) update the state to avoid wasting any future effort on new notification generation.
One of the core principles of delay loading is that you get failures at the time of use (in the default config). Checking beforehand is a bit of a waste of time in that case... and the cost of one miss when accessibility is enabled on a very rarely-used platform is not high enough to make me want to do any preflight checking :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectively, this is "try to notify, stop ever trying again if it fails", which means we don't complicate any other codepaths.
There are other places where we could "pre"check, and none of them sound great to me. Here's where--and why.
- We could check when a HwndTerminalAutomationPeer is constructed
- This might happen on startup, which moves the loading of UIAutomationCore back onto the startup path
- We could check at the top of this function
- Doing this only once requires a magic static, which requires a thread local storage slot and a lock to ensure exclusivity
/DELAYLOAD
operating as normal is cheaper than both of those 😄
We could also just not store the failure state and let the delayload failure trip every time. It's not THAT expensive... but it could fire once per keyboard input (!) or any text output (!) in the worst case.
UiaRaiseNotificationEvent is not present on Windows Server 2016, even though it is documented as being present. This also removes the cost of loading up UIAutomationCore from the critical path. (cherry picked from commit 99c18ce) Service-Card-Id: 89704753 Service-Version: 1.17
UiaRaiseNotificationEvent is not present on Windows Server 2016, even though it is documented as being present. This also removes the cost of loading up UIAutomationCore from the critical path. (cherry picked from commit 99c18ce) Service-Card-Id: 89704754 Service-Version: 1.18
UiaRaiseNotificationEvent is not present on Windows Server 2016, even though it is documented as being present.
This also removes the cost of loading up UIAutomationCore from the critical path.