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

WinEvents and ConPTY question #1811

Closed
parkovski opened this issue Jul 3, 2019 · 4 comments
Closed

WinEvents and ConPTY question #1811

parkovski opened this issue Jul 3, 2019 · 4 comments
Assignees
Labels
Area-Interop Communication between processes Issue-Question For questions or discussion Product-Conpty For console issues specifically related to conpty Resolution-Answered Related to questions that have been answered

Comments

@parkovski
Copy link

A few days ago I noticed that NeoVim in tmux does not pick up resize events properly, but mysteriously when a different console window is resized, it suddenly fixes itself. I just tracked this down to the fact that libuv is listening for the EVENT_CONSOLE_LAYOUT WinEvent for any window, which doesn't seem to be firing for PTY layout changes.

Now, I believe this is a libuv bug and they should be handling WINDOW_BUFFER_SIZE_EVENT. But before ConPTY existed, their way did work.

Basically I'm looking for some clarification here - what are the console WinEvents supposed to be for, and should they be enabled for PTYs as well? And if not, it might be a good idea to document that they are only sent for actual conhost windows.

@parkovski parkovski added the Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs label Jul 3, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jul 3, 2019
@DHowett-MSFT
Copy link
Contributor

Hey, it's really funny that you should mention this. I'm working on filing a bug on them for this exact issue, because their winevent hook degrades performance for all console workloads by a few percentage points if a libuv thing is running whatsoever.

I believe that WinEvents are not part of the compatibility guarantee for pseudoconsoles. @miniksa can keep me honest here.

@oising
Copy link
Collaborator

oising commented Jul 4, 2019

More info: #410 @parkovski

@miniksa
Copy link
Member

miniksa commented Jul 5, 2019

Hey, it's really funny that you should mention this. I'm working on filing a bug on them for this exact issue, because their winevent hook degrades performance for all console workloads by a few percentage points if a libuv thing is running whatsoever.

I believe that WinEvents are not part of the compatibility guarantee for pseudoconsoles. @miniksa can keep me honest here.

Correct. Given that UIA (released 2005) is the replacement for WinEvents/MSAA (released 1997) and UIA is significantly less terrible than MSAA performance-wise (and otherwise), we didn't consider it during the implementation of ConPTY (2018).

Also, MSAA and UIA are for accessibility tools and user interface testing. I don't guarantee anything if you're not attempting to use them for those purposes.

@DHowett-MSFT DHowett-MSFT added Area-Interop Communication between processes Issue-Question For questions or discussion Product-Conpty For console issues specifically related to conpty Resolution-Answered Related to questions that have been answered and removed Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs labels Jul 8, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 8, 2019
@DHowett-MSFT DHowett-MSFT added Needs-Tag-Fix Doesn't match tag requirements and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jul 8, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 8, 2019
@DHowett-MSFT
Copy link
Contributor

I'm marking this one as answered and closing it. I'll follow up with the libuv bug. 😄

bzoz added a commit to JaneaSystems/libuv that referenced this issue Jul 18, 2019
Continuing improvement of SIGWINCH from PR libuv#2308.

Running SetWinEventHook without filtering for the specific PIDs has
significant impact on the performance of the entire system. This PR
changes the way SIGWINCH is handled.

The SetWinEventHook callback now signals a separate thread,
uv__tty_console_resize_watcher_thread. This thread calls
uv__tty_console_signal_resize() which checks if the console was actually
resized. The uv__tty_console_resize_watcher_thread makes sure to not to
call the uv__tty_console_signal_resize function more than 30 times per
second.

The SetWinEventHook will not be installed, if the PID of the
conhost.exe process that owns the console window cannot be
determinated. This can happen when a 32bit libuv app is running on a
64bit Windows.

For such cases PR libuv#1408 is partially reverted - when tty reads
WINDOW_BUFFER_SIZE_EVENT, it will also trigger a call to
uv__tty_console_signal_resize(). This will also help when the app is
running under console emulators. Documentation was alos updated to
reflect that.

Refs: microsoft/terminal#1811
Refs: microsoft/terminal#410
Refs: libuv#2308
bzoz added a commit to JaneaSystems/libuv that referenced this issue Sep 5, 2019
Continuing improvement of SIGWINCH from PR libuv#2308.

Running SetWinEventHook without filtering for the specific PIDs has
significant impact on the performance of the entire system. This PR
changes the way SIGWINCH is handled.

The SetWinEventHook callback now signals a separate thread,
uv__tty_console_resize_watcher_thread. This thread calls
uv__tty_console_signal_resize() which checks if the console was actually
resized. The uv__tty_console_resize_watcher_thread makes sure to not to
call the uv__tty_console_signal_resize function more than 30 times per
second.

The SetWinEventHook will not be installed, if the PID of the
conhost.exe process that owns the console window cannot be
determinated. This can happen when a 32bit libuv app is running on a
64bit Windows.

For such cases PR libuv#1408 is partially reverted - when tty reads
WINDOW_BUFFER_SIZE_EVENT, it will also trigger a call to
uv__tty_console_signal_resize(). This will also help when the app is
running under console emulators. Documentation was alos updated to
reflect that.

Refs: microsoft/terminal#1811
Refs: microsoft/terminal#410
Refs: libuv#2308
bzoz added a commit to libuv/libuv that referenced this issue Sep 5, 2019
Continuing improvement of SIGWINCH from PR #2308.

Running SetWinEventHook without filtering for the specific PIDs has
significant impact on the performance of the entire system. This PR
changes the way SIGWINCH is handled.

The SetWinEventHook callback now signals a separate thread,
uv__tty_console_resize_watcher_thread. This thread calls
uv__tty_console_signal_resize() which checks if the console was actually
resized. The uv__tty_console_resize_watcher_thread makes sure to not to
call the uv__tty_console_signal_resize function more than 30 times per
second.

The SetWinEventHook will not be installed, if the PID of the
conhost.exe process that owns the console window cannot be
determinated. This can happen when a 32bit libuv app is running on a
64bit Windows.

For such cases PR #1408 is partially reverted - when tty reads
WINDOW_BUFFER_SIZE_EVENT, it will also trigger a call to
uv__tty_console_signal_resize(). This will also help when the app is
running under console emulators. Documentation was also updated to
reflect that.

Refs: microsoft/terminal#1811
Refs: microsoft/terminal#410
Refs: #2308

PR-URL: #2381
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interop Communication between processes Issue-Question For questions or discussion Product-Conpty For console issues specifically related to conpty Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

5 participants