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

ConPTY not emitting OSC sequences longer than 256 characters (Windows 10) #15551

Closed
segrey opened this issue Jun 14, 2023 · 5 comments
Closed
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@segrey
Copy link

segrey commented Jun 14, 2023

Windows Terminal version

1.17.11461.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

You need Windows 10 to reproduce this. Not reproduced for me on Windows 11.

  1. Open forked GUIConsole.ConPTY. It runs the following PowerShell script under the hood:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::Write("1")
[Console]::Write("$([char]0x1B)]42;$("a" * 5)`a")
[Console]::Write("2")
[Console]::Write("$([char]0x1B)]42;$("b" * 250)`a")
[Console]::Write("3")
[Console]::Write("$([char]0x1B)]42;$("c" * 251)`a")
[Console]::Write("4")
[Console]::Write("$([char]0x1B)]42;$("d" * 252)`a")
[Console]::Write("5")
[Console]::Write("$([char]0x1B)]42;$("e" * 253)`a")
  1. Run it in Windows Terminal. The following will be printed:
PS C:\Users\serge\sandbox\terminal\samples\ConPTY\GUIConsole\GUIConsole.ConPTY\bin\Debug\net7.0> .\GUIConsole.ConPTY.exe
Starting OSC-seq-example.ps1
stdout (length=356):
1dee2345
Found 7 sequences:
ESC[2J
ESC[m
ESC[H
ESC]0;C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe^G
ESC[?25h1
ESC]42;aaaaa^G
ESC]42;bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^G^Gd^Gee^G2345

Expected Behavior

Visible printed text should be 12345.
The output should contain 5 OSC escape sequences:

  1. OSC 42 ; a x5
  2. OSC 42 ; b x250
  3. OSC 42 ; c x251
  4. OSC 42 ; d x252
  5. OSC 42 ; e x253

Actual Behavior

Instead, the visible printed text is 1dee2345.
The output contains only the first two escape sequnces:

  1. OSC 42 ; a x5
  2. OSC 42 ; b x250

Seems ConPTY cannot emit escape sequences longer than 256 characters. Are there any workarounds?

@segrey segrey added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 14, 2023
@DHowett
Copy link
Member

DHowett commented Jun 14, 2023

Interesting!

It looks like this works with the version of ConPTY in Terminal 1.18!

image

(The debug panel on the right shows conpty's raw output before Terminal parses it for display on the left.)

The version of ConPTY shipped in Windows 10 is quite out of date compared to what ships in Terminal, and it's difficult for applications to get access to. We're tracking making that easier in #15065.

Unfortunately, you may need to wait until that one lands. Sorry! /dup #15065

@microsoft-github-policy-service
Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 14, 2023
@segrey
Copy link
Author

segrey commented Jun 15, 2023

@DHowett Perfect, thanks for the quick response!

Probably, it's not needed as you've got my case right, but I feel like I should have clarified it a bit. My application similarly to the forked GUIConsole.ConPTY loads ConPTY from Windows system libraries. There is no such issue when the PowerShell commands (like [Console]::Write("HELLO$([char]0x1B)]42;$("c" * 1024)$([char]0x07)WORLD")) are run directly in Windows Terminal 1.17.11461.0. The problem occurs when they are run in PowerShell which is run with ConPTY loaded from Windows system libraries.

Thanks for #15065. While it's unavailable yet, do you know if there are any workarounds for the ConPTY version shipped in Windows 10?

Oh, more importantly, how can I detect if a loaded ConPTY version contains the fix for this issue?

@DHowett
Copy link
Member

DHowett commented Jun 15, 2023

Unfortunately, I don't have a very good answer for those two questions. There isn't a workaround (I believe the bug is actually that on occasion, the console host receives the OSC in more than one WriteConsole call and we didn't have OSC fragment collection until #4870 landed (which shipped in Windows in build 19611.) It was pretty busted before that.

It's unfortunately not detectable. Any version you get from a prospective or potential nuget package will have the fix, and any version on Windows 10.0.20348 and above will have the fix. That's Server 2022... 🤔

@segrey
Copy link
Author

segrey commented Jun 16, 2023

Great, thanks for the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

2 participants