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

Intense black flickering and artifacts on Windows #875

Closed
luleyleo opened this issue Apr 24, 2020 · 9 comments · Fixed by #885
Closed

Intense black flickering and artifacts on Windows #875

luleyleo opened this issue Apr 24, 2020 · 9 comments · Fixed by #885
Labels
bug does not behave the way it is supposed to shell/win concerns the Windows backend

Comments

@luleyleo
Copy link
Collaborator

To check out what the invalidation example looks like on Windows for #872 and noticed intense flickering and rendering artifacts since partial invalidation (#817) has been merged.
Resetting druid to the last commit before the PR was merged gets rid of the flickering.

Does this happen on normal Windows? Or can someone else reproduce this for a VM?

@luleyleo luleyleo added bug does not behave the way it is supposed to question causes uncertainty shell/win concerns the Windows backend labels Apr 24, 2020
@raphlinus
Copy link
Contributor

Yes, this is broken for me too 😢

@luleyleo luleyleo removed the question causes uncertainty label Apr 24, 2020
@luleyleo luleyleo changed the title Intense black flickering and artifacts inside Windows VM Intense black flickering and artifacts inside on Windows Apr 24, 2020
@luleyleo luleyleo changed the title Intense black flickering and artifacts inside on Windows Intense black flickering and artifacts on Windows Apr 24, 2020
@luleyleo
Copy link
Collaborator Author

@jneem do you have any ideas what could cause this?

@jneem
Copy link
Collaborator

jneem commented Apr 24, 2020

Sorry about that, I don't know the cause but I'll try to get a windows VM to check it out.

In the meantime, if you change handle.invalidate_rect in druid/src/window.rs to handle.invalidate, does it fix the flickering?

@luleyleo
Copy link
Collaborator Author

@jneem yes, that gets rid of the flickering
Do you have time right now to dig into this or should we disable invalidate_rect for now?

@jneem
Copy link
Collaborator

jneem commented Apr 24, 2020

I can start looking into it as soon as the VM image finishes downloading. I have no idea how long it will take, though, so maybe disable it for now.

luleyleo added a commit to luleyleo/druid that referenced this issue Apr 24, 2020
luleyleo added a commit to luleyleo/druid that referenced this issue Apr 24, 2020
@jneem
Copy link
Collaborator

jneem commented Apr 25, 2020

On windows, I'm having issues with rendering even prior to partial invalidation. If you look at my test branch here, I've reverted to an earlier commit and introduced the example druid-shell/examples/invalidate.rs. This example doesn't do partial invalidation (because it doesn't exist yet); all it does is draw a new rectangle (in a different position) every time it paints. I'm getting a lot of artifacts, including a sort of "shaking" where it looks like the canvas is moving between frames. I can get the artifacts to stop by either

  • dragging the window (as long as I'm dragging it, it looks good), or
  • changing the default PresentStrategy to Hwnd.

I tried to capture it, but the capture software I tried (OBS studio) doesn't capture it properly unless I change the PresentStrategy to Hwnd.

@xStrom
Copy link
Member

xStrom commented Apr 28, 2020

I tested this on two physical computers with Windows.

Windows 7

Works just fine, probably because it uses PresentStrategy::Hwnd.

Windows 10

Has flicker problems, although there are no weird artifacts, black rects, or shaking. Instead the problem seems to be rather specific and reproducable.

  1. I click on the right side to set the circle on the bottom
  2. I click again to move the circle to the top
  3. I go to the left side of the window with my mouse
    • When the mouse is over a button everything seems fine
    • When the mouse is over the background then on the right side it shows the older bottom circle

So when I just move the mouse over all the buttons, the right side flickers between the circle being at the top and bottom.

@jneem
Copy link
Collaborator

jneem commented Apr 28, 2020

Thanks for checking this out! So I've spent some time reading the docs, and I think the issue is that IDXGISwapChain is using multiple buffers (possibly overlapping?) in the background, and it uses different buffers on different frames. That's why we sometimes see flickering and shaking (flipping between buffers that are partly black, or are overlapping), and it also explains your incorrect circle position (because one of the buffers has the circle in the wrong place).

It appears that IDXGISwapChain::Present1 has some parameters to pass information about invalid rects, and I guess I need to use them. I'll see if I can figure them out later today or tomorrow.

@raphlinus
Copy link
Contributor

Yes, swapchains use multiple buffers, this is generally true in any high performance presentation framework, as using a single buffer entails copying. Also yes, IDXGISwapChain::Present1 is the right API to use for incremental presentation on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug does not behave the way it is supposed to shell/win concerns the Windows backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants