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

Window resizing lags with white rectangles on Windows #5374

Open
Bromles opened this issue Mar 10, 2024 · 9 comments
Open

Window resizing lags with white rectangles on Windows #5374

Bromles opened this issue Mar 10, 2024 · 9 comments
Labels
area: wsi Issues with swapchain management or windowing backend: dx12 Issues with DX12 or DXGI backend: vulkan Issues with Vulkan platform: windows Issues with integration with windows type: enhancement New feature or request

Comments

@Bromles
Copy link

Bromles commented Mar 10, 2024

Description
When resizing a window on Windows, strange white rectangles underneath it become visible (example in the video in the extra materials). The problem is present with both Vulkan and DX12 backends. Also, I tested the same code on an M1 Mac and it doesn't have this issue. So I think this may be specific to Windows.

Repro steps
Despite the fact that the video was recorded on my project, the issue is present even when running unchanged examples from the wgpu repository, for instance, hello_triangle.

Extra materials

2024-03-10.17-51-12.mp4

Platform

  • Windows 11 Enterprise 22H2 (22631.3235)
  • Nvidia RTX 3090 Ti
  • Studio Driver 551.61
  • wgpu 0.19
  • winit 0.29
@Bromles
Copy link
Author

Bromles commented Mar 10, 2024

I just tested the hello_triangle example on trunk, v0.19, v0.18, v0.17 and v0.16 branches, and the problem remains everywhere. It is possible that there is a bug in the drivers, or the problem was there from the beginning

@Bromles
Copy link
Author

Bromles commented Mar 10, 2024

Also, GL backend works just fine even on Windows, the issue persists only on Vulkan and DX12 backends

@Bromles
Copy link
Author

Bromles commented Mar 10, 2024

Made an interesting observation. These are not white rectangles, it looks like a white surface the size of a window that appears in it before the wgpu's surface is rendered. Initially, when the window appears, it is completely filled with white, and only then the image is drawn there. As you make the window smaller, there is a delay in reducing the white surface size, causing it to become visible. However, having decreased once, it does not increase back when the window size increases, and due to this, during subsequent resizes, the lagging part is transparent (if the window has transparency enabled) or black (if not)

I have attached a video illustrating this behavior

2024-03-10_20-20-19.mp4

@Wumpf
Copy link
Member

Wumpf commented Mar 23, 2024

@Gremious
Copy link

Gremious commented Apr 6, 2024

It happens to me as well, and it's pretty noticable. Found it as I was trying to make an iced app and the window resizing was very slow and laggy, even in release. Then found out the wgpu examples had the same issue.

6VfvMMJZhw.mp4

(the video is running the example in debug but release still does much the same, just slightly less)

I also get tons of errors in the console:

[2024-04-06T18:01:19Z ERROR wgpu_hal::auxil::dxgi::exception] ID3D12CommandQueue::ExecuteCommandLists: Using ClearRenderTargetView on Command List (0x000001900AF9ACD0:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x7F2F4CB0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) of resource (0x000001900AF92E00:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a render target.  Expected State Bits (all): 0x7F2F4C90: D3D12_RESOURCE_STATE_RENDER_TARGET, Actual State: 0x7F2F4C70: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Missing State: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

[2024-04-06T18:01:19Z ERROR wgpu_hal::auxil::dxgi::exception] ID3D12CommandQueue::ExecuteCommandLists: Using IDXGISwapChain::Present on Command List (0x000001900A77C040:'Internal DXGI CommandList'): Resource state (0x7F2F47D0: D3D12_RESOURCE_STATE_RENDER_TARGET) of resource (0x000001900AF92E00:'Unnamed ID3D12Resource Object') (subresource: 0) is invalid for use as a PRESENT_SOURCE.  Expected State Bits (all): 0x7F2F47B0: D3D12_RESOURCE_STATE_[COMMON|PRESENT], Actual State: 0x7F2F4790: D3D12_RESOURCE_STATE_RENDER_TARGET, Missing State: 0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]. [ EXECUTION ERROR #538: INVALID_SUBRESOURCE_STATE]

(second line spams as I resize)

Am on windows 11.

@eseaflower
Copy link

I think this might be related DXGI swap chains and the Windows DWM. We have had a lot of issues with this but not clean solution. There is a long (very long) rant/write up on resizing behavior here https://stackoverflow.com/questions/53000291/how-to-smooth-ugly-jitter-flicker-jumping-when-resizing-windows-especially-drag. The author is not very happy and goes into some rants, but he has done some solid research into the problem.

@CatCode79
Copy link
Contributor

I found an article written by Raph Levien about this very problem:
https://raphlinus.github.io/rust/gui/2019/06/21/smooth-resize-test.html

@cwfitzgerald
Copy link
Member

@Bromles there's kinda slim chance, but can you try #5681 to see if this fixes your issue?

@Bromles
Copy link
Author

Bromles commented Jul 20, 2024

@cwfitzgerald Sorry for late reply, I somehow missed notification.

Just tried your branch on hello_triangle example, the issue remains unchanged.

@cwfitzgerald cwfitzgerald added type: enhancement New feature or request backend: dx12 Issues with DX12 or DXGI backend: vulkan Issues with Vulkan area: wsi Issues with swapchain management or windowing platform: windows Issues with integration with windows labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: wsi Issues with swapchain management or windowing backend: dx12 Issues with DX12 or DXGI backend: vulkan Issues with Vulkan platform: windows Issues with integration with windows type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants