-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Move all blink handling into Renderer #19330
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
4de989d
to
8d17e85
Compare
8d17e85
to
8390d60
Compare
Goal: Remove `CursorBlinker`. Problem: Spooky action at a distance via `Cursor::HasMoved`. Solution: Moved all the a11y event raising into `_stream.cpp` and pray for the best. Goal: Prevent node.js from tanking conhost performance via MSAA (WHY). Problem: `ServiceLocator`. Solution: Unserviced the locator. Debounced event raising. Performance increased by >10x. Problem 2: Lots of files changed. This PR is a prerequisite for #19330 ## Validation Steps Performed Ran NVDA with and without UIA enabled and with different delays. ✅
8390d60
to
5742c64
Compare
5742c64
to
1c23430
Compare
__declspec(dllexport) HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ til::CoordType width, _In_ til::CoordType height, _Out_ til::size* dimensions); | ||
__declspec(dllexport) void _stdcall TerminalDpiChanged(void* terminal, int newDpi); | ||
__declspec(dllexport) void _stdcall TerminalUserScroll(void* terminal, int viewTop); | ||
__declspec(dllexport) void _stdcall TerminalClearSelection(void* terminal); |
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.
@DHowett Curious. Since VS is a consumer here, do we just notify them of these changes? Is there anything special we have to be aware of with the partnership?
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.
(as below)
void _stdcall TerminalClearSelection(void* terminal) | ||
try | ||
{ | ||
const auto publicTerminal = static_cast<HwndTerminal*>(terminal); | ||
const auto lock = publicTerminal->_terminal->LockForWriting(); | ||
publicTerminal->_ClearSelection(); | ||
} | ||
CATCH_LOG() | ||
|
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.
Is there a reason we're removing this one? Doesn't seem related to the cursor blink changes, and it's removing an API, right?
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.
So, the good news about all of the Terminal*
APIs inside HwndTerminal.cpp
is that they are all internal. They are a contract between the WPF control and the TermControl. We can change them practically at-will. :)
|
||
void _stdcall TerminalSetCursorVisible(void* terminal, const bool visible) | ||
try | ||
void HwndTerminal::_setFocused(bool focused) noexcept |
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.
Big fan of this. It's nice that it's all in one function 😊
#define FOREACH_ENGINE(var) \ | ||
for (auto var : _engines) \ | ||
if (!var) \ | ||
break; \ | ||
else |
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.
Huh. We don't need the if (!var) break
anymore?
else if (!IsTimerRunning(_cursorBlinker)) | ||
{ | ||
const auto actual = GetTimerInterval(_cursorBlinker); | ||
auto expected = _pData->GetBlinkInterval(); |
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.
auto expected = _pData->GetBlinkInterval(); | |
const auto expected = _pData->GetBlinkInterval(); |
const?
|
||
bool RenderData::IsUiaDataInitialized() const noexcept | ||
{ | ||
return true; |
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.
(Double checking) In terminalrenderdata.cpp, we have this:
terminal/src/cascadia/TerminalCore/terminalrenderdata.cpp
Lines 226 to 234 in 1b712b2
bool Terminal::IsUiaDataInitialized() const noexcept | |
{ | |
// GH#11135: Windows Terminal needs to create and return an automation peer | |
// when a screen reader requests it. However, the terminal might not be fully | |
// initialized yet. So we use this to check if any crucial components of | |
// UiaData are not yet initialized. | |
_assertLocked(); | |
return !!_mainBuffer; | |
} |
We don't need to check the buffer here?
// initialize cursor GH#4102 - Typically, the cursor is set to on by the | ||
// cursor blinker. Unfortunately, in conpty mode, there is no cursor | ||
// blinker. So, in conpty mode, we need to leave the cursor on always. The | ||
// cursor can still be set to hidden, and whether the cursor should be | ||
// blinking will still be passed through to the terminal, but internally, | ||
// the cursor should always be on. | ||
// | ||
// In particular, some applications make use of a calling | ||
// `SetConsoleScreenBuffer` and `SetCursorPosition` without printing any | ||
// text in between these calls. If we initialize the cursor to Off in conpty | ||
// mode, then the cursor will remain off until they print text. This can | ||
// lead to alignment problems in the terminal, because we won't move the | ||
// terminal's cursor in this _exact_ scenario. | ||
screenInfo.GetTextBuffer().GetCursor().SetIsOn(gci.IsInVtIoMode()); | ||
|
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.
Hmm... Do we need to worry about this scenario still?
// We trigger a scroll rather than a redraw, since that's more efficient, | ||
// but we need to turn the cursor off before doing so; otherwise, a ghost | ||
// cursor can be left behind in the previous position. |
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.
update the comment?
Note that this PR is not quite finished (~90%?). Missing:
This PR moves the cursor blinker and VT blink rendition timer into
Renderer
. To do so, this PR introduces a generic timer system with which you can schedule arbitrary timer jobs. Thanks to this, this PR removes a crapton of code, particularly throughout conhost, and improves throughput by another ~10%. On my PC it can now churn through >400MB/s while rendering at 240FPS. Fun fact: Processing 100kB of text and rendering it in conhost now takes less time than MSCTF (TSF) needs to process 1 keyboard character. When I look at our shell code.Validation Steps Performed