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

Console Host redraws the current line after every character #1877

Closed
DHowett opened this issue Aug 18, 2016 · 10 comments
Closed

Console Host redraws the current line after every character #1877

DHowett opened this issue Aug 18, 2016 · 10 comments
Assignees
Labels
Resolution-External The issue is caused by external component(s). WG-Engine-Performance core PowerShell engine, interpreter, and runtime performance WG-Interactive-PSReadLine PSReadline related issues

Comments

@DHowett
Copy link

DHowett commented Aug 18, 2016

Steps to reproduce

Launch powershell. Type a command.
Observe that the cursor flickers left and right, back and forth, for every character you type.
This may require a terminal with slower refresh.

Expected behavior

The input is only redrawn when it becomes necessary.

Actual behavior

The input is redrawn for every input character.

I profiled this, and found that for the input (and output):

PS > powershell redraws a lot

... which is a paltry few bytes, we emit 52,501 bytes of ANSI escape sequences repositioning the cursor, drawing colours, repositioning the cursor some more, etc.

Environment data

root@f49460ec9455:/# powershell -c '$PSVersionTable'

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@andyleejordan andyleejordan added the WG-Interactive-PSReadLine PSReadline related issues label Aug 18, 2016
@DHowett
Copy link
Author

DHowett commented Aug 18, 2016

Thought: perhaps this is to mimic the Windows console's support for drawing characters at any coordinates (without cursor moves)? It looks like we could be trying to do the same thing, but because it's being used to such a high degree we're emitting a veritable boatload of CSIs.

It's especially noticeable over remote links with nonzero latency.

@lzybkr
Copy link
Member

lzybkr commented Aug 18, 2016

The current design exists to keep things simple - e.g. the color of text previously entered might change after typing a character. The current design also performs much better on Windows than the simple alternatives.

At any rate, thanks for the report, this is a known issue that we definitely plan on addressing.

@lzybkr lzybkr added the WG-Engine-Performance core PowerShell engine, interpreter, and runtime performance label Aug 18, 2016
@lzybkr lzybkr self-assigned this Aug 24, 2016
@lzybkr lzybkr added this to the 6.0.0-alpha.11 milestone Sep 12, 2016
@lzybkr
Copy link
Member

lzybkr commented Nov 9, 2016

This issue was moved to PowerShell/PSReadLine#469

@lzybkr lzybkr closed this as completed Nov 9, 2016
@joeyaiello joeyaiello added the Resolution-External The issue is caused by external component(s). label Nov 29, 2016
@masaeedu
Copy link

@lzybkr Is there a workaround for this? Still seeing this in the latest container published on docker. I don't know if it's extra noticeable for me because my machine sucks, but it makes it very difficult to do any useful work.

@masaeedu
Copy link

masaeedu commented Apr 12, 2017

Nvm, just found it. For posterity:

Remove-Module -Name PSReadline

EDIT: While this works, make sure you don't use the up or down keys after removing the module or the session will crash.

@iSazonov
Copy link
Collaborator

@masaeedu Thanks for your report! Please open Issue about the session crash.

@masaeedu
Copy link

@iSazonov Is this another PSReadline bug or should I open it for this repo?

@iSazonov
Copy link
Collaborator

@masaeedu If the crash happens without PSReadline the Issue is for this repo.

@masaeedu
Copy link

@iSazonov The crash happens specifically when you remove PSReadLine from a running session, and I suspect the issue is that PSReadLine takes over some hooks for navigating history that don't get reset to their original state when you unload the module. In other words PSReadLine probably isn't designed to be Remove-Moduled, which is fine because removing it isn't a common use case.

You'd have to start up powershell without PSReadLine loaded at all to determine whether the problem is independent of PSReadLine, and I don't know how to do that.

@iSazonov
Copy link
Collaborator

@masaeedu I cannot repo this. So you can open Issue in this repo. Later we can move it in PSReadLine repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-External The issue is caused by external component(s). WG-Engine-Performance core PowerShell engine, interpreter, and runtime performance WG-Interactive-PSReadLine PSReadline related issues
Projects
None yet
Development

No branches or pull requests

7 participants