Multiple pointer events in one frame

Dear community,

I noticed some peculiar behavior while profiling code with the PointerDragBehavior: For each animation frame, multiple pointer move events seem to be processed. Especially if the code executed during each pointer move event is slow, this seems to increase the CPU usage unnecessarily. Is there some special reason why those events are processed up to four times when rendering a single frame? Can I disable it somehow, am I missing something?

I attached the playground I used to reproduce the behavior and a screenshot of the profiler:

Bildschirmfoto 2022-01-25 um 13.27.42

Kind regards,
Zacherl

Adding @PolygonalSun the input guru.

1 Like

Hey @zacherl,
There were some changes to the underlying input system to allow for tracking of specific changes to clientX, clientY, movementX, and movementY. Unfortunately, it’s also firing certain observables for each of these and I am actively working on a fix/optimization for this.

2 Likes

Thanks a lot for that update, @PolygonalSun . Is there some issue on Github I could watch? And I have hardly any experience with the underlying code of the framework, but if you think I could help, I would be happy to do so.

So for this issue, we were initially tracking as a part of a bigger task that was in the pipeline. Given the particular nature of this, I created a separate issue for it as I wanted to push up the timeline for its integration:
DeviceInputSystem: Reduce calls to onInputChanged for pointer movements · Issue #11859 · BabylonJS/Babylon.js (github.com)

If you’re interested in learning more about our framework and possibly contributing to it, check out our GitHub page. We always appreciate help from the community and couldn’t have grown without them.