-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
git: cursor droppings have returned to the world #804
Comments
Also needs repro because I didn't come up with a perfectly consistent repro of this yet to narrow it down. |
From #1128 # Environment
Steps to reproduce
Note that this seems to happen intermittently but was very easy to reproduce (noticed it within seconds of upgrading last night). Expected behaviorThe cursor from the previous line should dissappear after you hit Enter. Actual behaviorThe cursor stays drawn on the previous line: e.g. |
I'm sorry for being a pain, but was just curious what the plan is to resolve this one? Is it something that can be rolled out with a hotfix or will it need to wait until the next major release? Kindest Regards |
This kind of thing won't be serviceable (hotfixable") unfortunately. Hopefully it'll be in the 20H1 release of Windows 10, so long as the fix is found before that. |
No worries, thanks a lot for the reply! |
I'm not convinced this is the source of the issue, but note that PowerShell generates a new line, and scrolls the viewport, via a completely different code path to the one used by the cmd.exe shell, or a WSL bash shell. PowerShell relies on Looking at some of the differences between those two code paths, though, one thing I found that seemed to help some of the time, was adding a call to I'm not sure this really tells you anything, but that's all I've been able to figure out so far. |
I think the issue is because when you scroll:
So the 2 inverts don't cancel each other out and the old cursor cursor ends up being painted in the window context. If I comment out line 78 the bug is fixed for me. |
I can confirm that works for me too, at least in both of the cases that I knew would fail before. But I'm curious why it was only a problem for certain types of scrolling. Why was this fix only needed for PowerShell when all the shells are using the same renderer? |
@j4james I suspect that fix takes care of both scenarios. The problem was surfacing with (at least) a blinking cursor, I believe when the scroll operation was performed while the cursor was in a visible state -- potentially even in a race between the mem dc and the ps dc. Let's say you have visible lines 1-3, already scrolled, and line 2 in error displays a static cursor due to this bug. On next line-scroll, line 2 could turn off that cursor (since the two DC's were out of synch), and instead render cursors for line 1, 3. That bug was almost a given, since it's pretty much impossible to maintain synchronizations like that (be it GDI or data across some other arbitrary asynchronous domains). Let this be a lesson on data synchronization across domains, and the difficulty thereof. |
OK I think I know what's going on now, and why commenting out line 78 is probably not the right solution. Whenever the cursor renders with an When the cursor has blinked off, though, the The reason this is a problem in Powershell, but not in the cmd shell, is because the latter turns the cursor on when scrolling (as I mentioned above). This results in both the old and new cursor positions being repainted when the cursor is moved, so any incorrect Now commenting out line 78 does kind of fix the problem, because that essentially disables this What I think is the correct solution, is that we need to reset the That seems to be fix the problem for me in Powershell, and without the ghosting effect, but I haven't been able to reproduce the git case anymore, so I can't be absolutely certain that one is fixed too. However, I'm confident enough in this approach that I'd like to submit a PR for it, if nobody has any objections. At the very least it'll be an improvement on the current situation. |
Wow that's a great analysis. I certainly don't have any objections. These cursor droppings issues always come and go as we meddle with the renderer, so I wouldn't be surprised if the original issue doesn't repro anymore. However, if you've got a repro and fix for #1128, then let's do it |
There are certain cursor movement operations (in conhost) that can result in "ghost" cursor instances being left behind, if the move causes the viewport to scroll while the cursor is blinking off. Pressing enter in a PowerShell prompt when at the bottom of the screen was one example of this. This PR fixes that problem. Whenever the cursor renders with an `InvertRect`, the affected areas of the screen are saved in the `cursorInvertRects` variable. If the screen is then scrolled while the cursor is visible, those rects are "uninverted" in the `GdiEngine::ScrollFrame` method before the scrolling takes place. When the cursor has blinked off, though, the `GdiEngine::PaintCursor` method won't set the `cursorInvertRects` variable, but it also doesn't clear it. So if the screen is scrolled at that point, the `ScrollFrame` method tries to "uninvert" the area where the cursor had previously been painted. And since the cursor is no longer there, this has the opposite effect, leaving an unwanted mark on the screen. I've fixed this by clearing the `cursorInvertRects` at the start of the paint cycle, in the the `GdiEngine::PaintBackground` method. Since this occurs after the `ScrollFrame` step, it still allows for legitimate cursor instances to be cleaned up when scrolling, but makes sure that the variable will be cleared for the next cycle if the cursor is no longer visible. ## Validation Steps Performed I've manually verified that I no longer see ghost cursor fragments when scrolling in PowerShell. Closes #804
Ported from internal issue MSFT: 19744641
The "cursor droppings" issue is where there are just left behind cursors somewhere on the renderer window. I know this affects
conhost.exe
. I'm not sure if it affectswindowsterminal.exe
yet. The filing says use GDI renderer, but that doesn't mean the underlying problem isn't in theCursor
class or something and would affect the DX renderer too.The text was updated successfully, but these errors were encountered: