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

High input latency with wgpu backend #5037

Open
mrjbom opened this issue Aug 30, 2024 · 10 comments
Open

High input latency with wgpu backend #5037

mrjbom opened this issue Aug 30, 2024 · 10 comments
Labels
bug Something is broken egui-wgpu help wanted Extra attention is needed

Comments

@mrjbom
Copy link

mrjbom commented Aug 30, 2024

Describe the bug
In the demo application, there is a delay in the application's response to input: windows move with a delay, elements react to the mouse over them with a delay, and button presses also have a delay.
This issue is present in 0.28.1 and the master branch.

egui.delay.mp4

In my application, I also encountered this delay (Windows, Vulkan backend, egui-wgpu 0.28.1, and egui-winit 0.28.1). I found that the delay depends on the backend: it is lower on DX12 than on Vulkan.

I tested everything on release versions.
The web version with egui.rs works fine.

At first, it seemed to me that I was doing something wrong in my application when I encountered this issue, but since it also occurs in the demo application, it seems the problem isn't related to something else; maybe it's with egui-wgpu.

@mrjbom mrjbom added the bug Something is broken label Aug 30, 2024
@emilk emilk added the egui-wgpu label Sep 1, 2024
@emilk
Copy link
Owner

emilk commented Sep 1, 2024

Related:

Please see if changing the value of WgpuConfiguration::desired_maximum_frame_latency to Some(1) helps

@emilk emilk added this to the Next Major Release milestone Sep 1, 2024
@mrjbom
Copy link
Author

mrjbom commented Sep 1, 2024

Please see if changing the value of WgpuConfiguration::desired_maximum_frame_latency to Some(1) helps

Can I configure this using egui_wgpu::renderer::Renderer? I using Renderer now

@emilk
Copy link
Owner

emilk commented Sep 1, 2024

@mrjbom
Copy link
Author

mrjbom commented Sep 1, 2024

Then you want https://docs.rs/wgpu/latest/wgpu/type.SurfaceConfiguration.html#structfield.desired_maximum_frame_latency

I tried changing the value here from 2 to 1 and it didn't help.

@emilk
Copy link
Owner

emilk commented Sep 1, 2024

I still suspect a latency issue with triple (or more) buffering in wgpu - maybe @Wumpf can chime in with more info

@mrjbom
Copy link
Author

mrjbom commented Sep 1, 2024

I still suspect a latency issue with triple (or more) buffering in wgpu - maybe @Wumpf can chime in with more info

Definitely a wgpu problem, there is no delay only if present mode is Immediate or Mailbox.

@mrjbom
Copy link
Author

mrjbom commented Sep 1, 2024

I tested how a pure Vulkan application behaves with the FIFO present mode, which is the default for PresentMode in wgpu, and I also encountered delays.
This seems to be an issue with FIFO itself, not wgpu only; it's probably better to choose Immediate or Mailbox to avoid delays.

@Wumpf
Copy link
Collaborator

Wumpf commented Sep 2, 2024

I'm on vacation and also not super knowledgable about the myriad of fine details here, but maybe @cwfitzgerald wants to chime in :)
Thanks @mrjbom for digging that deep already! It's still curious that DX12 behaves differently on FIFO, worth figuring out why that is.

This sounds vaguely familiar to some issues Bevy folks reported after some severe bugs in Vulkan's synchronization code got fixed.

@mrjbom
Copy link
Author

mrjbom commented Sep 2, 2024

I tried to show and compare what delay is present and under which API and modes, I think it will be useful.

delays.compare.2.mp4

@mrjbom
Copy link
Author

mrjbom commented Sep 2, 2024

The egui_demo_app screen at the top seems to use glow.

No, the logs say that wgpu is being used

@emilk emilk changed the title Delays in the demo app High input latency with wgpu backend Sep 10, 2024
@emilk emilk added this to egui Dec 11, 2024
@emilk emilk removed this from the Next Major Release milestone Dec 11, 2024
@emilk emilk added the help wanted Extra attention is needed label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui-wgpu help wanted Extra attention is needed
Projects
Status: No status
Development

No branches or pull requests

3 participants