ConPTY Passthrough mode #1173
Comments
|
@zadjii-msft was looking into this. The main issue, if I recall correctly, is that we need to trash the entire buffer when something enters or exits “passthrough” mode. It’s also only truly applicable when there is a connected pseudoconsole session. |
|
And the reason one console might enter and exit passthrough mode multiple times is that you may run Additional concerns: if you have a tree of four processes, each of which wants passthrough to be different, should the ones that are doing It’s complicated when you get into compatibility discussions. |
|
Yea, I tried getting this working for like a day last year, but it's something I've wanted to work on for a while. As Dustin mentioned, there'd be real weirdness moving between passthrough mode and non-passthrough mode. However, I think it might still be something good to investigate. |
|
From #1985:
|
|
We need a |
|
This is an essential feature for opening MS text-mode software (esp. WSL) to 3rd-party environments.
It should be a combined mode: Whenever a console-API-based application is run, e.g. as started from a pure terminal-based application, the console API calls should be transformed into terminal escape sequences. Note as there are not so many features in the console API, this is a much easier approach than the reverse mapping, trying to squeeze terminal features through the conhost bottleneck. |
|
Just realized #2035 is this ask framed differently.
Not just progress. Behavior. This guy is writing a Tek4010 emulator. He is going to need a PTY if say his code were ever ported to native win32. And
That too. Doesn't have to be a signal, mind, if there is some religious/philosophical reasons against. But if not it needs to be a separate (third rail) |
|
@mintty |
Great. Invent a new CSI sequence for that. Send the |
I assume this concern is more about the other direction of such adaptation, i.e. how would you serve a Windows console program that wants to use that "absurd" feature? You could run a second, hidden console in parallel, to maintain backwards compatibility. |
The people who hate how ConPTY is implemented today will absolutely hate how it's implemented if we do that. |
|
They wouldn't even notice in pure pass-through applications. It might be necessary to solve an otherwise unresolvable dilemma. |
This solution makes no sense because there is no window in To the point of #2035, neither
Yes. And as a practical matter I wouldn't expect the
I think we are closer than that. If ...So long as it is quiet about it. There is no reason for a pass-through "mode", which is how this issue was framed. There is never a reason for ConPTY to inject a VT sequence into a [Then we need |
|
Like it or not, conhost is the API server that, regardless of whether it presents a window, makes all existing Win32 console applications work. It must continue to make those applications work, because organizations really I think you're looking to turn this request, and this project, into something it's not. You may be attempting to turn ConPTY exists to--narrowly-stated--allow an application that understands a number of sequences as specified by an xterm-256color terminfo to host a windows console application; to wit: an application that would otherwise run in conhost should be able to run in a "terminal emulator" of sufficient compatibility. It's not intended to support a TEK4010 application (those are not windows console subsystem applications), and it's not likely to want to support a TEK4010 terminal emulator that is expecting to receive a bytestream from a TEK4010 application. That guy will probably end up doing what everybody ELSE who doesn't want to write a windows console subsystem application does: use pipes, because they don't have the same compatibility requirements (neé guarantees) as the windows pseudoconsole infrastructure. Through that lens, a "passthrough" mode is required. A console application by default, and this cannot be changed for compatibility reasons, starts up in a mode where it just has full access to all of the stupid Win32 console APIs that no terminal emulator developer wants to countenance. Nobody should be able to read back the contents of a terminal buffer, local or remote, that they wrote to. Nobody should be able to write into the offscreen section of the buffer, because there's no guarantee anywhere else that it actually exists. But, they do. Developers use this. Applications expect this, because they were written as windows console subsystem applications. A passthrough mode--mode!--is the only way we can offer an application a way to say "I promise I won't use the old ways" while still being a windows console subsystem application. That's the first step we can make towards ConPTY being the dumb pipe you want it to be. If you'd like to debate whether the Windows Console was the right choice, or was well-designed, I'm happy to have you do it--but not here. Two asides.
|
|
I'm not intending to criticize the design or implementation -- at all. That was not the intent. I am trying (more slowly than intended) to find a solution to open-for-a-year issue WSL#3279. Of which Biswa96 has a very good start. |
|
woah this thread got pretty out of hand over the weekend. The stars aligned Friday, and I actually got a chance to play around with implementing a passthrough mode for conpty. I'm pretty happy with how it works so far, so I think it needs a spec and some polish, and maybe we can ship it one day. Here's the approach I've been taking:
This provides a way where we can be sure that apps that weren't updated for running in a pty will still have access to the entire console API, but apps that want to live in the new world can say "I promise I know what I'm doing", and run even smoother in conpty. I believe there's going to be an incredibly small intersection of apps that want to use VT and also call things like |
|
Thanks to everyone working on this! I've been hoping to see this for some time, so very excited to see progress!
I just wanted to weigh in that passthrough-by-default seems highly desirable to me. If I'm reading right, passthrough will result in faster and better rendering (e.g. resolves #405) more or less universally. The only downside is that it would break compatibility with some console APIs (which cross-platform VT-based apps will not need). So it seems to me that a good balance would be:
Also some interesting questions which just struck me:
|
|
A further thought: will the hosting terminal emulators be able to query if the pseudoconsole is in passthrough mode? This might be needed, for example when the window resizes:
|
|
I think if the terminal emulators request a ConPTY and state whether or not
to to get pass through mode, then the terminal emulator already knows what
to do in such circumstances.
…On Mon, 9 Dec 2019, 06:51 David Hewitt ***@***.***> wrote:
A further thought: will the hosting terminal emulators be able to query if
the pseudoconsole is in passthrough mode? This might be needed, for example
when the window resizes:
- If it is in passthrough, then the terminal emulator should perform
text reflow when the window resizes
- If it is not in passthrough, then ConPTY will perfom text reflow (so
the terminal emulator should not)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1173?email_source=notifications&email_token=AAAN3O2FBNHB5LIVP5O22FDQXXMHZA5CNFSM4HWHDMHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGH5QDA#issuecomment-563075084>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAN3OYWW4ENVN5F3DALG4TQXXMHZANCNFSM4HWHDMHA>
.
|
Sure; however it sounded to me like for the solution proposed here the commandline app would request passthrough mode, rather than the terminal emulator. So the terminal emulator would have no knowledge of whether passthrough mode is enabled. |
|
IMHO it doesn't make sense for the app (running inside a terminal emulator)
to request passthrough mode but the terminal emulator, the one to interpret
the VT sequences, must see the VT sequences as equivalent as possible to
what the app produced. ?The problem with ConPTY is, that it is going to
reimplement every single VT sequence out there, and it lags behind. Hence,
terminal emulator writers where reporting bugs (or missing features), and
the best way to work around that is to "just pass all VT sequences through
\"as-is\"", eliminating a whole range of issues within ConPTY, and thus,
giving the terminal emulator the chance to actually see what the apps
produce, and render that.
The app inside any terminal emulator, while it should know when it is going
to be resized, should not care about what terminal emulator of
man-in-the-middle (conpty) it is running in. Do you agree?
Am Mo., 9. Dez. 2019 um 08:51 Uhr schrieb David Hewitt <
notifications@github.com>:
… I think if the terminal emulators request a ConPTY and state whether or not
to to get pass through mode, then the terminal emulator already knows what
to do in such circumstances.
Sure; however it sounded to me like for the solution proposed here the
commandline app would request passthrough mode, rather than the terminal
emulator. So the terminal emulator would have no knowledge of whether
passthrough mode is enabled.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1173?email_source=notifications&email_token=AAAN3OYOEQS5Q5RM5ORTTG3QXX2G7A5CNFSM4HWHDMHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGIF25I#issuecomment-563109237>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAN3O4XF6KLNQELYXBXMJLQXX2G7ANCNFSM4HWHDMHA>
.
|
|
@christianparpart sometimes, there are no VT sequences coming out of an application. The Windows Console APIs are not implemented using VT sequences. The terminal cannot set passthrough mode because it cannot force legacy applications to become compatible with VT sequences. This is why ConPTY exists. |
|
For a terminal, whether conhost is in ConPTY or passthrough mode should be irrelevant, because the terminal application will just receive VT sequences through the PTY pipe. |
That's my point; it's not irrelevant in certain edge cases. For example when the window resizes: at the moment ConPTY reflows its buffer and sends the terminal emulator instructions to redraw everything. In passthrough mode this won't happen, so the terminal emulator will have to do reflow itself. |
|
Idea: Perhaps an |
No, the use case is a terminal running a specific backend, particularly WSL, so it knows the client will use VT mode and passthrough is needed to give it full functionality.
The terminal would "normally" notify the pty about changed terminal size. The pty would then send a SIGWINCH signal to the client application. ConPTY should handle this signal forwarding somehow. Then the client application can redraw itself. |
I disagree. Knowledge that passthrough is needed for full functionality would be better written once in the client app (e.g.
Agreed (I think it might already send this signal?). But I'm not talking about SIGWINCH here. I'm talking about the terminal emulator's own text layout & redraw, such as wrapping overflowing lines. At the moment ConPTY does line wrapping on its internal buffer and sends VT output to the emulator on how to draw the wrapped text. In passthrough mode the emulator will get unwrapped text and need to wrap it itself. |
…h the frame
## Summary of the Pull Request
When Conpty encounters a string we don't understand, immediately flush the frame.
## References
This PR superceeds #2665. This solution is much simpler than what was proposed in that PR.
As mentioned in #2665: "This might have some long-term consequences for #1173."
## PR Checklist
* [x] Closes #2011
* [x] Closes #4106
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
When ConPTY encounters a string we don't understand, immediately flush the frame. ## References This PR supersedes #2665. This solution is much simpler than what was proposed in that PR. As mentioned in #2665: "This might have some long-term consequences for #1173." ## PR Checklist * [x] Closes #2011 * [x] Closes #4106 * [x] I work here * [x] Tests added/passed
Modern apps won’t read the hidden character grid and do everything in VT. So why not an API/console mode to tell Console Host to completely throw away that?
The text was updated successfully, but these errors were encountered: