-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Frame rate drop caused by high polling rate mouse #12679
Comments
Are you able to reproduce this is in pure |
I've tested the egui_demo_app and a demo in the fyrox tutorial, and both experience significant frame rate drops when using a high polling rate mouse. Therefore, it's likely that the problem lies within winit. I found a winit issue that may be related to this problem: rust-windowing/winit#1418 |
Awesome, that's very useful information. Thank you for investigating! |
I found the problem and made a pull request to winit rust-windowing/winit#3609. Edit: This breaks some handling of winit. Additional fixes needed. |
On my opened issue on winit I noted that I tested your pull but with no success, it made no difference between before / after the pull was added, if you have or want more information let me know. Wanted to share this here because this is recent and seems highly relevant to this issue! Note that I tried making a window with winit and with winapi directly, both had performance issues, so I suspect it's windows especially after my profiling results, so the only fix would be to find a workaround |
After getting a high polling rate mouse recently, I investigated this issue a little bit and here's what I found:
The winit issue was closed but I wonder whether it's worth opening a new one seeing as it might be possible to improve performance using the technique from the article. |
Bevy Version
0.13.1
System Information
SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "AMD Ryzen 9 7940HS w/ Radeon 780M Graphics", core_count: "8", memory: "15.2 GiB" }
AdapterInfo { name: "NVIDIA GeForce RTX 4060 Laptop GPU", vendor: 4318, device: 10464, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "536.45", backend: Vulkan }
What Went Wrong
I have a mouse that allows me to adjust its polling rate. There are no issues when the mouse's polling rate is below 2000Hz. However, when I set the polling rate to 4000Hz, even in the simplest scenes, rapidly moving the mouse causes a significant drop in frame rate, with the maximum frame time increasing from around 10ms to about 80ms. Minimal example
1000Hz:
![1000Hz_frame_time](https://private-user-images.githubusercontent.com/91826964/316283661-68732942-8c48-4894-848b-db738da1550b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDIwMDIsIm5iZiI6MTczOTcwMTcwMiwicGF0aCI6Ii85MTgyNjk2NC8zMTYyODM2NjEtNjg3MzI5NDItOGM0OC00ODk0LTg0OGItZGI3MzhkYTE1NTBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwMjgyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJmYTg2M2M2MTAzNTM5M2FmYjg0MWMzODJiMjkzNTEzYzIxOTRmNDliZDBiMzE2YmVhZmNjOGE1YTUzNmNmZTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Bq0AAC83RIVpJcVj-TP2NJVVU8Eq9SYu4l_GXMCrTeE)
4000Hz:
![4000Hz_frame_time](https://private-user-images.githubusercontent.com/91826964/316283665-d2c35e60-319f-43d7-8acc-fe0fb10c6d73.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDIwMDIsIm5iZiI6MTczOTcwMTcwMiwicGF0aCI6Ii85MTgyNjk2NC8zMTYyODM2NjUtZDJjMzVlNjAtMzE5Zi00M2Q3LThhY2MtZmUwZmIxMGM2ZDczLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwMjgyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU1ZDQ0NWMwN2Y1M2FjY2ZjNDcxNzE0ZWNlNTExZDc4NTZjZTE1NjJmMWFmY2JkNTVmZDc4ZDM4YWRhZGYxNDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.d5Dl9UlAUFzVTREnmZU4i1Zsi6iLBxp6nlP8Hc9OI8I)
What You Did
Since I haven't encountered similar issues in Godot and some games, it likely isn't a problem with the performance of my computer.
I tried using
PresentMode::Fifo
,PresentMode::Mailbox
, andPresentMode::Immediate
, but the frame drops did not improve.I attempted the method from SDL#8756 using GetRawInputBuffer to acquire raw mouse input in a dedicated thread (my code), yet there was still no improvement.
Tracing data shows a lot of
CursorMoved
events between two frames when using a 4000Hz polling rate. I tried commenting out the code handlingCursorMoved
in bevy_winit and settingevent_loop.listen_device_events(DeviceEvents::Never)
, but these did not solve the problem.1000Hz:
![1000Hz_trace](https://private-user-images.githubusercontent.com/91826964/316283698-dbc70f62-b4dd-48d3-8618-36d383051556.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDIwMDIsIm5iZiI6MTczOTcwMTcwMiwicGF0aCI6Ii85MTgyNjk2NC8zMTYyODM2OTgtZGJjNzBmNjItYjRkZC00OGQzLTg2MTgtMzZkMzgzMDUxNTU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwMjgyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThjYTZmY2U4ZGFkYTI0YzIzMDQzNmQzZjk5NDY2OGNlZDQ5ZTFlZTVmNDE0MmU4N2I3ZDYxYTk0NDI2MGFjYmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.XwSYhgNcS0iKTWB1Hejr4xy-CUAfrLbJROwtzG5oYX8)
4000Hz:
![4000Hz_trace](https://private-user-images.githubusercontent.com/91826964/316283704-47cc0a57-8d71-43d7-a6c3-24c5f00ad40c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDIwMDIsIm5iZiI6MTczOTcwMTcwMiwicGF0aCI6Ii85MTgyNjk2NC8zMTYyODM3MDQtNDdjYzBhNTctOGQ3MS00M2Q3LWE2YzMtMjRjNWYwMGFkNDBjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwMjgyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJkZjIwNzU0NmY3NDU3YmNmYzFiYjliMzFlZGRhM2YzMzBmMGE3N2JiNWI4ZmE1NGE2YjBiZjcyZTA2MDMxOTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.6-FUzZSHqN1Dja9hBZiFKp12acVM7bBAj3KATd_UrVE)
I suspect that some logic within bevy_winit or winit might be causing the stutter with high polling rate mice, but I haven't identified the cause. Do you have any idea?
The text was updated successfully, but these errors were encountered: