Open the-asind opened 4 months ago
I just opened up a PR to hopefully address this issue. Here is the root cause I found during my testing - this explanation is taken from the PR.
The bug was being caused because the value of InputEventScreenDrag.relative was sometimes being calculated with an event with a mismatched identifier/index. This happened because relative was being computed without checking if the coordinates of the point stored in the touches array in DisplayServerWeb had a matching identifier/index.
Consider the following example. A user has two fingers dragging on a touch screen. At frame 1, the TouchList of the touchmove event fired would contain two items: [{identifier: 0, clientX: 15, clientY: 110, ...}, {identifier: 1, clientX: 20, clientY: 110, ...}]. Let's say the finger for identifier: 0 stops moving, but is still touching the screen. The next time touchmove fires, the TouchList looks like this: [{identifier: 1, clientX: 5, clientY: 110, ...}]. So when relative for identifier: 1 is computed, it uses the TouchList from frame 1 to compute the value. As mentioned above, the current implementation assumes that the TouchList contains the same touch with the same identifier at the index it was last frame. But, this is not always the case. Therefore, this causes relative to be (10, 0) instead of the expected (15, 0).
Tested versions
Reproducible in:
System Information:
System information
Android 12-13, iOS 17, web, gl_compatible,
Issue description
When running in the web version of Godot Engine 4 (regardless of Thread Support), there are issues with the calculation of
event.relative
forInputEventScreenDrag
during multitouch. Specifically, other touches seem to influence the relative values of different touches, despite the position for each touch index remaining unchanged.In the video example, you can see that the right hand (which controls the camera) I'm barely moving (can be tracked by Position at index 0). And the actions of the second index clearly affect the relative of index 0
https://github.com/user-attachments/assets/f4eacb8d-1692-4f1e-8d1e-8111af22a11e
Steps to reproduce
event.relative
values.Expected Behavior: Each touch should independently have accurate
event.relative
values based on its movement, unaffected by other touches.Actual Behavior: The
event.relative
values are incorrectly influenced by other touches, resulting in erratic and incorrect behavior.Example Code with Issue:
Example Code with Fix (Reinventing
relative
):Minimal reproduction project (MRP)
First Person Controller.zip