Repository navigation
Rework TermControl's initialization - #5051
Dustin L. Howett (MSFT) (DHowett-MSFT) merged 3 commits into
Conversation
This commit rewrites a large swath of TermControl's initialization code.
* `TermControl` now _always_ has a `_terminal`; it will never be null
* Event registration for `_terminal` and any other available-at-init
fixtures has been moved into the constructor.
* Event handlers how more uniformly check `_closing` if they interact
with the _terminal.
* Swap chain attachment has been cleaned up and no longer uses a
coroutine when it's spawned from the UI thread.
* We have to register the renderer's swapchain change notification
handler after we set the swap chain, otherwise it'll call us back
when it initializes itself.
* `InitializeTerminal` now happens under the `_terminal`'s write lock
* Certain things that InitializeTerminal were calling themselves
attempted to take the lock. They no longer do so.
* TermControlAutomationPeer cannot take the read lock, because setting
the scrollbar's `Maximum` during `InitializeTerminal` will trigger
vivification of the automation peer tree; if it attempts to take the
lock it will deadlock during initialization.
* `BlinkCursor` was renamed to `CursorTimerTick` because it's the "Tick"
handler for the "CursorTimer".
* `DragDropHandler` was converted into a coroutine instead of just
_calling_ a coroutine.
Caveats:
Terminal may not have a `_buffer` until InitializeTerminal happens.
There's a nasty coupling between RenderTarget and TextBuffer that means
that we need to have a renderer before we have a buffer.
There's a second nasty coupling between RenderThread and Renderer: we
can't create a RenderThread during construction because it needs to be
given a renderer, and we can't create a Renderer during construction
because it needs a RenderThread. We don't want to kick off a thread
during construction.
Testing:
I wailed on this by opening and closing and resizing terminals and panes
and tabs, up to a hundred open tabs and one tab with 51 panes. I set one
tab to update the title as fast as it possibly could and tested
teardown, zoom, resize, mouse movement, etc. while this was all
happening.
Closes #4613.
|
I hate how I hodgepodge decided what gets and what doesn't get the lock. I/O should probably take the lock but contention could be huge for I/O and i don't want to exacerbate the problem where ^C is delayed during long streams... |
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
This seems fine to me, but maybe we should have the team self-host this for a while to check before merging this one, or at least get the internal selfhost on this for a while before pushing to the public.
Also mild worry that this will blow up #4608
| { | ||
| return false; | ||
| } | ||
| { // scope for terminalLock |
There was a problem hiding this comment.
Would it make more sense to just unlock the lock instead of introducing another scope? idk
There was a problem hiding this comment.
Generally I prefer scopes for these, but it is largely stylistic
| void ResetFontSize(); | ||
|
|
||
| winrt::fire_and_forget SwapChainChanged(); | ||
| winrt::fire_and_forget RenderEngineSwapChainChanged(); |
There was a problem hiding this comment.
The nit-iest nit: Are these supposed to be public? Private? I'd think both private, and both with _ prefixes on the names
There was a problem hiding this comment.
yeah i'm not sure why we made that one public
this file is huge and could use some organization
|
Mike Griese (@zadjii-msft) this is in selfhost if you want to wail on it. I might have found one crash; doing a |
|
Alright, this has been in test for 48 hours. I've found one crash, but it's in TerminalPage's handling of tabs. Perhaps this is it? |
|
Do we have a LOS on the TerminalPage crash, or how prevalant that crash might end up? |
|
Not yet, but bug incoming. It's a mismanagement of |
|
(not caused by this, just latent) |
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
Since the crash was pre-existing, then ![]()
|
🎉 Handy links: |
This commit rewrites a large swath of TermControl's initialization code.
TermControlnow always has a_terminal; it will never be null_terminaland any other available-at-initfixtures has been moved into the constructor.
_closingif they interactwith the _terminal.
coroutine when it's spawned from the UI thread.
handler after we set the swap chain, otherwise it'll call us back
when it initializes itself.
InitializeTerminalnow happens under the_terminal's write lockattempted to take the lock. They no longer do so.
the scrollbar's
MaximumduringInitializeTerminalwill triggervivification of the automation peer tree; if it attempts to take the
lock it will deadlock during initialization.
BlinkCursorwas renamed toCursorTimerTickbecause it's the "Tick"handler for the "CursorTimer".
DragDropHandlerwas converted into a coroutine instead of justcalling a coroutine.
Caveats:
Terminal may not have a
_bufferuntil InitializeTerminal happens.There's a nasty coupling between RenderTarget and TextBuffer that means
that we need to have a renderer before we have a buffer.
There's a second nasty coupling between RenderThread and Renderer: we
can't create a RenderThread during construction because it needs to be
given a renderer, and we can't create a Renderer during construction
because it needs a RenderThread. We don't want to kick off a thread
during construction.
Testing:
I wailed on this by opening and closing and resizing terminals and panes
and tabs, up to a hundred open tabs and one tab with 51 panes. I set one
tab to update the title as fast as it possibly could and tested
teardown, zoom, resize, mouse movement, etc. while this was all
happening.
Closes #4613.