Pointer capture failing for Babylon pointer observable during a scroll event

I am having issues with pointer capture on mobile, which I was able to recreate in this playground: https://playground.babylonjs.com/#MJNICE#1423

The playground has a scrollable list of divs, and a cube that rotates when dragging horizontally on the list. The divs are sending a pointer capture to the canvas, which I expect to send events to the Babylon observable. Initially, when dragging horizontally on the tile, the capture works correctly and the events are forwarded to the Babylon pointer observable, rotating the box. However after scrolling vertically on the list, pointer capture is broken for the Babylon observable, but not for a regular event listener.

Is this a bug or am I using pointer capture incorrectly?

I work with Jarred and here is a video of the issue

Did some debugging, and it seems the reason for this is, when the scroll happens, it fires a pointerCancelEvent, which calls _onDeviceDisconnected: https://github.com/BabylonJS/Babylon.js/blob/193f5354bb5cd78ad6d7b1b4dfe0a8c7fe75366d/packages/dev/core/src/DeviceInput/webDeviceInputSystem.ts#L613, which then calls _removeDevice https://github.com/BabylonJS/Babylon.js/blob/193f5354bb5cd78ad6d7b1b4dfe0a8c7fe75366d/packages/dev/core/src/DeviceInput/InputDevices/deviceSourceManager.ts#L148, and the device is never added again with _addDevice: https://github.com/BabylonJS/Babylon.js/blob/193f5354bb5cd78ad6d7b1b4dfe0a8c7fe75366d/packages/dev/core/src/DeviceInput/InputDevices/deviceSourceManager.ts#L130. Let me ping @PolygonalSun our king of inputs to check if this is expected or not :thinking:

1 Like

This behavior doesn’t look right to me. Lemme take a closer look.

2 Likes

Okay, so here’s what I think is happening. The way our input system is setup, it expects to get some kind of pointerdown event (touching down on screen) to recognize that touch is being started. It then releases the touch when it gets a pointerup event. The way this code is set up, it’s only getting pointermove events so things are getting out of sync. This is a bit of an edge case so I’m currently adding some code to account for this input scenario. I’ll update this thread when I have a PR live.

Sound great, thanks for the help!

PR with the fix has been merged: WebDeviceInputSystem: Add additional checks for pointermove started Touch events by PolygonalSun · Pull Request #14174 · BabylonJS/Babylon.js (github.com)

4 Likes

Hi @PolygonalSun I checked the playground and it is fixed with version 6.17.0.
I updated my local version to the same version and it seems to still be broken. The changelog doesn’t actually include your PR. Should I wait for the next version?

It might have been published right before the merge. The new version should be up on Thursday, can you check by then ?

Okay great, I’ll check then.

1 Like