Weird scrolling regression in the GDI renderer #17676

Closed
opened 2026-01-31 05:49:54 +00:00 by claunia · 8 comments
Owner

Originally created by @j4james on GitHub (Jun 11, 2022).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

Commit 75e462441d

Windows build number

10.0.19044.1706

Other Software

No response

Steps to reproduce

  1. Checkout commit ed27737233 or later.
  2. Make sure you've got the GDI renderer enabled in the registry (i.e. UseDx is 0).
  3. Build and run OpenConsole.
  4. Perform a directory listing to make the viewport scroll.
  5. Press enter a few times to scroll some more.

Expected Behavior

Just normal scrolling.

Actual Behavior

Random bits of the screen scrolling independently of each other. Here's an example of the sort of thing I end up with.

image

I'm not sure how I hadn't noticed this before, but I think I've been using the DX renderer and only recently switched back to GDI (that's the only renderer that seems to be affected).

/cc @lhecker I think this might be PR #13025 again.

Originally created by @j4james on GitHub (Jun 11, 2022). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version Commit 75e462441d8ce2e32a363ea2f66ad3a035c50f90 ### Windows build number 10.0.19044.1706 ### Other Software _No response_ ### Steps to reproduce 1. Checkout commit ed27737233714dea77877624d1beeb49e2ccd36e or later. 2. Make sure you've got the GDI renderer enabled in the registry (i.e. `UseDx` is 0). 3. Build and run OpenConsole. 4. Perform a directory listing to make the viewport scroll. 5. Press enter a few times to scroll some more. ### Expected Behavior Just normal scrolling. ### Actual Behavior Random bits of the screen scrolling independently of each other. Here's an example of the sort of thing I end up with. ![image](https://user-images.githubusercontent.com/4181424/173161769-13c40604-05fe-4d73-9567-776203ec67f4.png) I'm not sure how I hadn't noticed this before, but I think I've been using the DX renderer and only recently switched back to GDI (that's the only renderer that seems to be affected). /cc @lhecker I think this might be PR #13025 again.
Author
Owner

@lhecker commented on GitHub (Jun 11, 2022):

Thanks for finding all these! Also, I have to confess: I think I just realized that despite the large changes to the GDI engine, I'm not sure I ever seriously tested it with UseDx != 2. 😨 I'll try to fix this as soon as I can.

@lhecker commented on GitHub (Jun 11, 2022): Thanks for finding all these! Also, I have to confess: I think I just realized that despite the large changes to the GDI engine, I'm not sure I ever seriously tested it with `UseDx != 2`. 😨 I'll try to fix this as soon as I can.
Author
Owner

@lhecker commented on GitHub (Jun 11, 2022):

Hmm... weird. I'm unable to reproduce the issue so far. I've tried it at 100%, 150% and 200% zoom scale. I've deleted all keys/values under HKCU:\Console before testing and I'm using a debug build of OpenConsole.

@lhecker commented on GitHub (Jun 11, 2022): Hmm... weird. I'm unable to reproduce the issue so far. I've tried it at 100%, 150% and 200% zoom scale. I've deleted all keys/values under `HKCU:\Console` before testing and I'm using a debug build of OpenConsole.
Author
Owner

@j4james commented on GitHub (Jun 11, 2022):

OK, let me try clear out my reg keys and see if I can narrow down a cause. But I can tell you my scale is 200% and I'm using a release build.

@j4james commented on GitHub (Jun 11, 2022): OK, let me try clear out my reg keys and see if I can narrow down a cause. But I can tell you my scale is 200% and I'm using a release build.
Author
Owner

@j4james commented on GitHub (Jun 11, 2022):

I tried deleting everything under HKCU\Console and I'm still seeing the problem. It couldn't be a Windows version thing could it? I'm assuming you're on Windows 11 and I'm still on 10.

But if you can't reproduce it, I'll try and look at the code and see if I can figure out where it's going wrong.

@j4james commented on GitHub (Jun 11, 2022): I tried deleting everything under HKCU\Console and I'm still seeing the problem. It couldn't be a Windows version thing could it? I'm assuming you're on Windows 11 and I'm still on 10. But if you can't reproduce it, I'll try and look at the code and see if I can figure out where it's going wrong.
Author
Owner

@lhecker commented on GitHub (Jun 11, 2022):

This could also be a difference due to our hardware. I could imagine that my Nvidia GPU might redraw the entire window according to the GDI information it has on every frame, whereas yours might strictly use the given dirty areas instead.

I do have a Windows 10 Hyper-V VM, which seems to reproduce the issue.
I could've sworn that I saw "ghost characters" seldomly while scrolling slowly up and down, but they always disappeared within a split second. This makes it certainly very hard to debug. 😅
(This also explains why I didn't notice it during testing...)

@lhecker commented on GitHub (Jun 11, 2022): This could also be a difference due to our hardware. I could imagine that my Nvidia GPU might redraw the entire window according to the GDI information it has on every frame, whereas yours might strictly use the given dirty areas instead. I do have a Windows 10 Hyper-V VM, which _seems_ to reproduce the issue. I could've sworn that I saw "ghost characters" seldomly while scrolling slowly up and down, but they always disappeared within a split second. This makes it certainly very hard to debug. 😅 (This also explains why I didn't notice it during testing...)
Author
Owner

@j4james commented on GitHub (Jun 11, 2022):

I think I've found the culprit.

ed27737233/src/renderer/gdi/paint.cpp (L124-L126)

That rcScrollLimit used to be initialized as:

RECT rcScrollLimit = { 0 };

But now it's not, so the left and top coordinates can end up with garbage values. I suspect it doesn't affect you because the debug build initializes everything on the stack to zero anyway.

@j4james commented on GitHub (Jun 11, 2022): I think I've found the culprit. https://github.com/microsoft/terminal/blob/ed27737233714dea77877624d1beeb49e2ccd36e/src/renderer/gdi/paint.cpp#L124-L126 That `rcScrollLimit` used to be initialized as: RECT rcScrollLimit = { 0 }; But now it's not, so the left and top coordinates can end up with garbage values. I suspect it doesn't affect you because the debug build initializes everything on the stack to zero anyway.
Author
Owner

@lhecker commented on GitHub (Jun 11, 2022):

Oh nice find! I actually tried it with a Release build as well...

@lhecker commented on GitHub (Jun 11, 2022): Oh nice find! I actually tried it with a Release build as well...
Author
Owner

@lhecker commented on GitHub (Jun 11, 2022):

I'll try to see if I can automate searching the large diff for similar mistakes somehow.
And I'll submit a PR for it as soon as possible. (I'll add you as Co-Authored-By if you don't mind. 🙂)

@lhecker commented on GitHub (Jun 11, 2022): I'll try to see if I can automate searching the large diff for similar mistakes somehow. And I'll submit a PR for it as soon as possible. (I'll add you as `Co-Authored-By` if you don't mind. 🙂)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17676