-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Description
Discussed in #19371
Originally posted by MamiyaOtaru September 23, 2025
I've made use of the WPF Control and mitchcapper's https://github.com/mitchcapper/EasyWindowsTerminalControl to create a simple tabbed terminal. Been fun reading OSC codes and changing the color or text on tabs etc.
BUT rapidly opening new tabs frequently leads to deadlocks.
The hang seems to be related to HwndTerminal.TerminalSetCursorVisible() and its use of _terminal->LockForWriting()
I can avoid them for the most part by handling and ignoring WM_KILLFOCUS in my main window but that makes setting focus to a new tab or a switched to tab very problematic and probably breaks other stuff.
Working much better is if I comment out
//NativeMethods.TerminalSetCursorVisible(this.terminal, false);
in case NativeMethods.WindowMessage.WM_KILLFOCUS:
in TerminalContainer.cs. With that I do not get the deadlocks. Downside: the cursor does not disappear when focus is lost (doesn't blink though!). That is an acceptable tradeoff for me. It is however annoying having to patch that with every release though rather than just using the latest .nupkg of Microsoft.Terminal.WPF
AFAICT what is happening with rapid presses of the new tab button is a new terminal is created, made visible, and then quickly unfocused when another new terminal in a new tab is created and somewhere in there a couple threads are waiting on a lock.
Anyway not sure if this is bug worthy. I don't think you have terminal.wpf out for general consumption yet and I am using it through a third party and probably abusing it by pressing that new tab button too much. But maybe there's something else I can do about it, or maybe a relatively easy way (for me) to replicate it indicates something can/should be done, dunno!
