-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Mouse Input Events called many times in between frames in 3.1 #26395
Comments
ping @hpvb |
I've noticed this as well when dealing with UI input. I have had to work around it with hacky flags. Thought maybe it was my hardware, so I hadn't reported it, but if others are seeing it as well, it likely is engine related. |
I don't this is a bug. Event.relative is relative to the last event's position so |
Perhaps I am thinking of something different. The issue I saw was specifically around mouse clicks. Eaxh click was firing multiple times for me. I just chalked it up to my laptop's touch pad. I havebt tried it on my desktop and I haven't tried since the 3.1 alphas. |
This is most likely due to raw input generating way more events. |
@reduz in current main (575f1d8) the problem is a lot smaller. In Beta8 count of input readings between frames was ~= 10 and in current main it's around 2. |
This should be tested in first-person projects to make sure it doesn't increase mouse latency. I think we should rather document this (along with ways to perform heavier processing in a real-time-friendly way). |
I created an issue after porting third person game (and tested in it as well), also as I said this is new behavior that was not present in 3.0 |
@Calinou no.. it should not matter for any type of game except for games that may need painting or very fine gestue recognition, which is not really common... guess will enable it. The reason it's happening now is most likely due to raw input being implmented on Windows and X11. |
An issue that arises from accumulating inputs for the whole frame is that input order is lost, i.e. the contextual position at which a button state change occurs relative to user motion during that frame cannot be determined because the engine dispatches them as a single event, effectively saying that "all of these events happened simultaneously". The higher the speed of user motion relative to the framerate, the more positional error this incurs. Suggestion: instead of accumulating the entire frame's worth of input events, partition the emitted events by types. If a sequence of events are of alike type, then accumulate them until the dispatcher encounters an unlike type (e.g. mouse motion [x10] -> keyboard press -> mouse motion [x3] -> keyboard release -> mouse motion [x13]) |
@xeonmc Input accumulation is currently disabled by default as the result of a bug: #55037 That said, when it was enabled by default, it worked out just fine in my experience. If you need more precision when input accumulation is enabled, godotengine/godot-proposals#2785 is a cleaner solution. |
The mentioned proposal solves the timing problem of velocity estimation, but not quite the order problem of button events being out of sequence from motion, at least not without the gamedev being aware of the quirk. According to the documentation for If the proposal is to be implemented in a way that maintains compatibility, it would need to do so via extending it with a new property of an array of timestamped vectors (x, y, t). However, because of the fact that the like-events are coalesced into the same event, the relative position of a button press in its motion sequence can only be retrieved by manually looping through the array and sort against the timestamps of the other event types. It's doable if the gamedev knows to do so beforehand, but ugly and kinda defeats the whole purpose of a timestamped sequence, especially when you tell a developer "oh hey timestamp info is also available", their expectation would be that it would be a singular timeline of events that they don't need to do extra stuff for. If we are sticking to the premise of only-one-event-per-type per frame when accumulation is enabled, then the only elegant way to solve it would be to add a new InputEvent type (maybe call it "InputEventTimeline") that contains the sequence of all events and their timestamp, which a gamedev can choose to use instead of monitoring the existing InputEvent types. Now you've basically just recreated the idea of the InputEvent queue, the only difference being Godot not explicitly dispatching them multiple times per frame. In that case, why not just implement it at the point where the accumulation is happening, and smartly dispatch them partitioned based on event type change? This way it ensures the correct sequence of arrival for events, while having the performance benefit of accumulation since it's unlikely that a player's finger is fast enough that he/she can emit buttonpresses multiple times within the same frame. |
@xeonmc Feel free to open a pull request for this 🙂 I haven't worked with the input event accumulation system, so I can't implement this myself. |
I'm not too familiar with the codebase, would you mind giving me (or point me to someone who can give me) a quick highlight of the relevant spots in the repo so I can start digging into it a bit quicker? GitHub search reveals some key points but I'm not confident about whether I missed something. Many thanks in advance. |
In Line 866 in d3a6b6d
You can also search for The project setting is called |
Godot version:
3.1 Beta 8
OS/device including version:
GTX1060, Ubuntu 18.04
Issue description:
I encouraged this issue couple of times already in different projects, at a first glance it looks like the mouse input is a lot weaker in 3.1. After some investigation it turned out that Mouse Input Events are called many many times in between frames in 3.1 and this can lead to at least two problems:
input
function)Steps to reproduce:
Quick way
Manual way
Minimal reproduction project:
weak_mouse_reproduction_3.0.zip
The text was updated successfully, but these errors were encountered: