-
-
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
200-250ms lag on 'mouse down' events on macOS #5778
Comments
What |
Thanks for responding! :) Just the default, as per https://github.com/bevyengine/bevy/blob/latest/examples/input/mouse_input.rs -edit- I believe the default is as follows:
|
handle_create_window_events(
&mut app.world,
event_loop,
&mut create_window_event_reader,
); This looks like the only section of that code that could have non-trivial cost then; I would start further investigation there. |
Thanks, unfortunately if i comment only that |
If i revert all my comments in bevy_winit/src/lib.rs, thus use vanilla bevy, and instead put the following in my main.rs, the lag goes away:
However i'm fairly sure ReactiveLowPower isn't what I want for an interactive game. |
I don't want to be presumptuous or crass... but is there a chance there's a bug bounty program? Could i get my company to chip in a bit to get someone with knowledge of the ECS to get this fixed? Is there some way the project coordinates requests like these, and how much should i offer? My apologies, but i tried following what was going on inside the ECS to find the culprit but it's amazingly complex code. Thanks as always, Bevy and the team are fantastic :) |
Ping @cart @mockersf @superdump for an answer on bug bounties :) |
I'm not sure I'm able to reproduce the issue, but then I may miss a 200ms difference I guess. Could you share the code you use to measure it? |
@mockersf I reproduce this by running the example here: https://github.com/bevyengine/bevy/blob/latest/examples/input/mouse_input.rs To get the timings, I made a local copy of bevy, changed my cargo.toml to point to that, and added println's (with times) to the event loop in bevy_winit/src/lib.rs/event_handler. I found a consistent 200-240ms between a 'TouchpadPressure' event and 'MouseInput' events. It looks like this:
Thanks again for the great framework. |
I can't reproduce on my Mac... Do you have an intel or a m1/m2? I have a m1 max It didn't seem to make a difference for me, but are you running in debug or release? |
Hi, I have a 2020 M1 air running Monterey (12.5.1) |
Just tried on my mac studio ultra and yes, have the same lag. |
There is no problem on my platform:
|
Thanks so much for attempting to reproduce this, i'm so grateful for your efforts :) |
Oh and i'm on bevy 0.8.1. Here's a slo-mo video demonstrating the delay, using the vanilla examples/input/mouse_input.rs. In a blue terminal window you'll see the current time in seconds. By looking at it frame-by-frame I came to the following measurements: Normal.with.lag.mp4lag video at 2s mark: lag video 31s mark: |
And for comparison, here it is with the ReactiveLowPower workaround. You can see the delay is only 90ms in this case, which i'm happy to put down to delay in the terminal etc. So if you subtract the baseline 90ms, I believe the problem is causing between 182 and 236ms delay in the first example. ReactiveLowPower.Workaround.mp4workaround video around 11s mark: workaround video around 32s mark: Hope that helps :) Thanks again everyone on this lovely framework and all the herculean efforts towards it! |
Ok! I appear to have stumbled across the culprit: I run an app called 'magnet' on my macs that gives keyboard shortcuts for moving your windows around. For some reason, when this is running, i have the delay, and when it is not running, there is no delay. I'll see if the developers of that app can fix it. Here's the app: https://apps.apple.com/au/app/magnet/id441258766?mt=12 I'm terribly sorry to have wasted your time! |
nice to hear you found the source of the delay! |
Bevy version 0.8
Relevant system information
macOS Monterey
What you did
I found that mouse click events were delayed in my game.
Here is the example: https://github.com/bevyengine/bevy/blob/latest/examples/input/mouse_input.rs
What went wrong
To reproduce this, I ran the bare-bones bevy input example linked below, and get the same result. With some logging I found the delay for mouse down is consistently 200-250ms. However there is 0 delay for mouse up.
Additional information
Since delayed mouse input is a deal-breaker for the use of Bevy for me, I spent quite a white trying to reproduce this.
I created a bare-bones example using Winit (not bevy at all) and mouse down and mouse up are instant - no delay, so i do not think there is an issue there.
I replicated Bevy locally and started commenting things out to see if i could isolate the issue, and if i comment out the following, there is no delay, so i assume the culprit is in there somewhere:
https://github.com/bevyengine/bevy/blob/latest/crates/bevy_winit/src/lib.rs
Comment out the body of the
event::Event::MainEventsCleared => {
match case, eg:Thanks for reading and thanks for the lovely game engine, I hope to be able to use it :)
The text was updated successfully, but these errors were encountered: