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

Wait before drawing the frame when receiving ESC[2J #16723

Closed
a-usr opened this issue Feb 16, 2024 · 4 comments
Closed

Wait before drawing the frame when receiving ESC[2J #16723

a-usr opened this issue Feb 16, 2024 · 4 comments
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@a-usr
Copy link

a-usr commented Feb 16, 2024

Description of the new feature/enhancement

Wait before drawing ( or creating ) a frame when ESC[2J (Clear Screen) is received until either a set time (e.g. 2 ms) has passed or additional data is received from stdout or stderr. This is to prevent flickering caused by applications (that do frame-based rendering, e.g TUI applications) that clear the screen before writing the next frame to it. If such a feature already exists, I propose making the timeout higher.

Worth noting is that the Flickering seems to be more intense on windows 11 vs on windows 10. Do the two platforms have different max framerates or is the framerate not capped at all and its caused by a hardware difference?

Proposed technical implementation details (optional)

@a-usr a-usr added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Feb 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 16, 2024
@a-usr
Copy link
Author

a-usr commented Feb 16, 2024

For additional context, apparently the Flickering doesnt seem to be an issue with other terminals like WezTerm, but I havent tested this myself.

@lhecker
Copy link
Member

lhecker commented Feb 17, 2024

In the current architecture it would be slightly difficult to implement this right now, but it would be generally possible long term. Your suggestion wouldn't work well over SSH though. Other terminals have since adopted iTerm2's synchronized update sequence (BSU = 2026) which does what you'd like but in a more robust manner. You can read about it here: https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec
Support for BSU is tracked in #8331. If that matches what you want, then I believe we should continue tracking this in #8331.

That said, and unrelated to the above, if you use the very latest Windows Terminal version and if you ensure to write your sequences in a single "packet" using the Windows APIs (= WriteFile on stdout) then it should not flicker.
C's printf for instance has an internal buffer size of 4KiB and any printf larger than that will chunk it up which causes flickering. WSL also does some buffering internally which causes the same thing. But if you use a native Windows function to write your output and buffer it properly then it should already work.

@a-usr
Copy link
Author

a-usr commented Feb 18, 2024

Thanks for the explanation and the references! Also huge thanks to you for taking your time and taking a look at almost every single issue👍

@a-usr a-usr closed this as completed Feb 18, 2024
@a-usr
Copy link
Author

a-usr commented Feb 19, 2024

Also I was wondering, is there any functionality to see when Windows Terminal receives a packet and what its contents are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

2 participants