Oculus Quest pointer ids

Hi,

there seem to be a weird issue with the pointer ids on the Oculus Quest.

If you are in 2D mode where the controller acts a mouse.
Whenever you press the controller a new pointerId is generated.
That is strange but not critical.

But in VR mode there is a bigger problem.
If you just entered VR. Everthing is fine.
As soon as you you take off the Quest and put it on again it is creating new pointer Ids.
If you then pull the trigger you are receiving an event for the new and an event for the old pointerId.
So if you repeat that process several times you will receive lots of pointer events all with differend pointerIds and targets.

Seems like this bug also has an effect on the angle of the right/left rotation.

I see this issue on the stable 4.0.3 and the latest 4.1.0-alpha.5.

Here is a Playground Links and some logs.

Just let me know if you need some additional information.

https://www.babylonjs-playground.com/#T10KKS#1

Initializing

|Babylon.js v4.1.0-alpha.15 - WebGL2
|[Violation] ‘readystatechange’ handler took 193ms
|babylon.js:16 [Violation] ‘setTimeout’ handler took 64ms

2D Mode. Controller acts as a mouse. Every click generates a new pointerId

|VM220:36 onPointerDown pointerId: 2
|VM220:36 onPointerDown pointerId: 3
|VM220:36 onPointerDown pointerId: 4

Entering VR

|VM220:40 onEnteringVR
|/#T10KKS#1:1 preserveDrawingBuffer was requested for context: it significantly affects rendering performance.
|babylon.js:16 submitFrame must be called within a VRDisplay.requestAnimationFrame callback.

Just entered VR. One click with the trigger creates one event. everything is OK.

|VM220:36 onPointerDown pointerId: 1

Take off the Quest and put it on again. Now a single click produces two events with different pointer ids

|VM220:36 onPointerDown pointerId: 1
|VM220:36 onPointerDown pointerId: 3

Take off the Quest and put it on again. Now a single click produces tree events with different pointer ids

|VM220:36 onPointerDown pointerId: 1
|VM220:36 onPointerDown pointerId: 3
|VM220:36 onPointerDown pointerId: 5

Pinging @RaananW to see if he can have a look (looks like we are missing an event when the oculus is took off).

Pinging @trevordev as well :slight_smile:

Interesting issue. Need to debug this, but I don’t have a quest…
I’ll dive into the code and see what can cause this. It seems like the event listeners are not being removed while new ones are added.
It’s an android system, right?

Yep I think so!

This is likely related to Babylon.js/vrExperienceHelper.ts at master · BabylonJS/Babylon.js · GitHub not being removed or Babylon.js/vrExperienceHelper.ts at master · BabylonJS/Babylon.js · GitHub not being fired when the headset is taken off

I am getting my quest in 2-3 days (same-day delivery… yeah, right), so I will be able to debug this better.

1 Like

If there is anything I can test / debug in order to support you, just let me know.

1 Like

Bumping this up and providing an explanation (but not yet a solution :slight_smile: )
The usual VR experience with general headsets (rift, vive, etc’) is that the gamepads stay connected all the time, so no new gamepad objects are being created. with the quest it is different - the gamepads are constantly disconnected and reconnected, but VR mode is still on (!!) (every time the display turns on - gamepad connected, off - gamepads disconnected). The VR Experience helper does not take it into account, to this - Babylon.js/vrExperienceHelper.ts at master · BabylonJS/Babylon.js · GitHub is not being reverted when a gamepad is disconnected.
We simply never had the case that gamepads are disconnected and reconnected :slight_smile:

So - Problem found, now to the solution. I will work on that. As I know what needs to be done now, the fix is rather trivial. you can track it here -

1 Like

Quick follow up -
the last PR I submitted (Update webVRController.ts by RaananW · Pull Request #6862 · BabylonJS/Babylon.js · GitHub) will fix this issue. It is actually rather straight-forward - the gamepads are being initialized again, meshes are loaded, and observables are cleared when they are not needed.
Note that the pointerId of the controllers will change every time you take the headset off and on, but during the session it will stay the same (unlike outside of the webvr session, then the browser causes the pointerId to increase constantly).