Discuss: Should ED 2 (EraseType::All) push text on the screen into the scrollback? #10983

Open
opened 2026-01-31 02:35:26 +00:00 by claunia · 8 comments
Owner

Originally created by @skyline75489 on GitHub (Oct 12, 2020).

Description of the new feature/enhancement

So I was investigating the "docker stats" flicking issue(#1680) and found something weird. The sequences generated by docker stats first erase-all then print the stats. The way conhost and WT implements this (ITerminalApi::EraseInDisplay), is to push everything on the screen into the scrollback and print new things:

image

Proposed technical implementation details (optional)

I don't know why this is like this but I'm sure there's a reason, and I feel that changing this might fix the flickering.

Originally created by @skyline75489 on GitHub (Oct 12, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement So I was investigating the "docker stats" flicking issue(#1680) and found something weird. The sequences generated by `docker stats` first erase-all then print the stats. The way conhost and WT implements this (ITerminalApi::EraseInDisplay), is to push everything on the screen into the scrollback and print new things: ![image](https://user-images.githubusercontent.com/4710575/95733627-fccef400-0cb4-11eb-8c29-c4f05c8f3915.png) <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> I don't know why this is like this but I'm sure there's a reason, and I feel that changing this might fix the flickering.
claunia added the Product-ConhostIssue-QuestionArea-VT labels 2026-01-31 02:35:27 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Oct 12, 2020):

I'm almost certain that's how it's supposed to work. IIRC, conhost did this wrong for our first few releases with VT support.

@j4james can put me on blast if I'm wrong about this

@zadjii-msft commented on GitHub (Oct 12, 2020): I'm almost _certain_ that's how it's supposed to work. IIRC, conhost did this wrong for our first few releases with VT support. @j4james can put me on blast if I'm wrong about this
Author
Owner

@skyline75489 commented on GitHub (Oct 12, 2020):

I was seeing a different behavior in wsltty which leads me to think that WT is weird. Then I confirmed that iTerm2 is also doing the same thing. So…guess I’m misunderstanding this. Still, this seems to be the root cause of the flickering, I think somewhere the refresh rate is limited by something.

获取 Outlook for iOShttps://aka.ms/o0ukef

@skyline75489 commented on GitHub (Oct 12, 2020): I was seeing a different behavior in wsltty which leads me to think that WT is weird. Then I confirmed that iTerm2 is also doing the same thing. So…guess I’m misunderstanding this. Still, this seems to be the root cause of the flickering, I think somewhere the refresh rate is limited by something. 获取 Outlook for iOS<https://aka.ms/o0ukef>
Author
Owner

@j4james commented on GitHub (Oct 12, 2020):

I'm honestly not sure where the idea of scrolling to clear the screen came from. The DEC STD 070 manual doesn't say anything about ED 2 scrolling, so I don't think think it's something the original hardware terminals did.

Some terminal emulators do scroll, and some don't. VTE is one popular example that does, while XTerm doesn't (at least by default - it might have an option somewhere for that). If we really want to be compatible with XTerm, we may want to consider disabling this by default, and maybe have an option to reenable it for those users that prefer the current behaviour.

As for the docker stats performance issue, is that a problem in conhost too? Because it occurred to me that it might just be relying on the alt buffer, which WT doesn't yet support (see #381). Clearing the screen while in the alt buffer shouldn't normally scroll anything because there is no scrollback, but that's not the case in WT.

@j4james commented on GitHub (Oct 12, 2020): I'm honestly not sure where the idea of scrolling to clear the screen came from. The DEC STD 070 manual doesn't say anything about ED 2 scrolling, so I don't think think it's something the original hardware terminals did. Some terminal emulators do scroll, and some don't. VTE is one popular example that does, while XTerm doesn't (at least by default - it might have an option somewhere for that). If we really want to be compatible with XTerm, we may want to consider disabling this by default, and maybe have an option to reenable it for those users that prefer the current behaviour. As for the docker stats performance issue, is that a problem in conhost too? Because it occurred to me that it might just be relying on the alt buffer, which WT doesn't yet support (see #381). Clearing the screen while in the alt buffer shouldn't normally scroll anything because there is no scrollback, but that's not the case in WT.
Author
Owner

@j4james commented on GitHub (Oct 12, 2020):

I just remembered there was some previous discussion on this subject in issue https://github.com/microsoft/terminal/issues/2832#issuecomment-533779605.

Also I think VTE was (and possibly still is) considering matching the XTerm behaviour (see here).

@j4james commented on GitHub (Oct 12, 2020): I just remembered there was some previous discussion on this subject in issue https://github.com/microsoft/terminal/issues/2832#issuecomment-533779605. Also I think VTE was (and possibly still is) considering matching the XTerm behaviour (see [here](https://bugzilla.gnome.org/show_bug.cgi?id=506438#c5)).
Author
Owner

@jack775544 commented on GitHub (Oct 12, 2020):

As for the docker stats performance issue, is that a problem in conhost too?

I checked this on both both conhost shipped in windows 2004 and OpenConsole shipped with terminal 1.4 and it still flashes the same as on WT.

@jack775544 commented on GitHub (Oct 12, 2020): >As for the docker stats performance issue, is that a problem in conhost too? I checked this on both both conhost shipped in windows 2004 and OpenConsole shipped with terminal 1.4 and it still flashes the same as on WT.
Author
Owner

@skyline75489 commented on GitHub (Oct 13, 2020):

I can also confirm the flickering in both conhost and WT. And no, it does not use alt buffer to my knowledge. It's just pure ED2 and print.

Because of the current clearing behavior, WT also has the same "Ctrl-L adding empty line" issue, as described in VTE 506438 and Konsole 384218. Also @egmontkob has filed this https://gitlab.gnome.org/GNOME/vte/-/issues/84 .

Interestingly, I can not reproduce the "Ctrl-L" bug in Ubuntu Terminal or kitty. I don't have KDE at hand so I can't check Konsole. And it is indeed an annoying bug if someone is using "Ctrl-L" a lot.

@skyline75489 commented on GitHub (Oct 13, 2020): I can also confirm the flickering in both conhost and WT. And no, it does not use alt buffer to my knowledge. It's just pure ED2 and print. Because of the current clearing behavior, WT also has the same "Ctrl-L adding empty line" issue, as described in [VTE 506438](https://bugzilla.gnome.org/show_bug.cgi?id=506438#c5) and [Konsole 384218](https://bugs.kde.org/show_bug.cgi?id=384218). Also @egmontkob has filed this https://gitlab.gnome.org/GNOME/vte/-/issues/84 . Interestingly, I can not reproduce the "Ctrl-L" bug in Ubuntu Terminal or kitty. I don't have KDE at hand so I can't check Konsole. And it is indeed an annoying bug if someone is using "Ctrl-L" a lot.
Author
Owner

@j4james commented on GitHub (Oct 13, 2020):

For the record, I'd be happy for us to make ED2 just clear the screen normally (i.e. matching the XTerm behaviour), unless there's evidence that the scrolling thing is an actual DEC standard (and I haven't seen anything suggesting that).

@j4james commented on GitHub (Oct 13, 2020): For the record, I'd be happy for us to make ED2 just clear the screen normally (i.e. matching the XTerm behaviour), unless there's evidence that the scrolling thing is an actual DEC standard (and I haven't seen anything suggesting that).
Author
Owner

@DHowett commented on GitHub (Oct 23, 2020):

I'm comfortable with the current scrolling behavior, but I'll keep this in our back pocket in case we want to change it.

If we really want to be compatible with XTerm ...

I'm honestly fifty-fifty on whether this is a compatibility break. There's a line between application-visible compatibility (sequences change the addressable buffer in a known way, colors are treated just so, etc.) and user-visible compatibility (scrollback acts like this, the mouse does this, etc.), and I prefer our xterm compatibility to be to be on the application side.

Xterm doesn't do a lot of the things we do, but if applications can't detect that chicanery I'm less worried about it. If we wanted to be xterm's user interface, we could cut out a whole bunch of our work!

I'm going to keep this one open as a discussion. I see the argument that it's unfortunate from a security perspective, but I know that we'd get a lot of flak for changing it.

@DHowett commented on GitHub (Oct 23, 2020): I'm comfortable with the current scrolling behavior, but I'll keep this in our back pocket in case we want to change it. > If we really want to be compatible with XTerm ... I'm honestly fifty-fifty on whether this is a compatibility break. There's a line between application-visible compatibility (sequences change the addressable buffer in a known way, colors are treated just so, etc.) and user-visible compatibility (scrollback acts like this, the mouse does this, etc.), and I prefer our xterm compatibility to be to be on the _application_ side. Xterm doesn't do a lot of the things we do, but if applications can't detect that chicanery I'm less worried about it. If we wanted to be _xterm's user interface_, we could cut out a whole bunch of our work! I'm going to keep this one open as a discussion. I see the argument that it's unfortunate from a security perspective, but I know that we'd get a lot of flak for changing it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10983