Hubs-Foundation / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubsfoundation.org
Mozilla Public License 2.0
2.13k stars 1.41k forks source link

Hands can appear above users head on Quest #1667

Open gfodor opened 5 years ago

gfodor commented 5 years ago

Description Sometimes, when entering a room, the avatar hands can appear floating above your head

To Reproduce Hard to repro, happens randomly on entry. I'm filing this bug because I determined that you can resolve the issue by existing and re-entering VR via the menu button, so it implies to me it's not bad gamepad tracking data as we expected.

Hardware Quest + Oculus Browser

gfodor commented 5 years ago

one theory i have is something is going wrong with the sitting to standing transform. if you see this bug occur, please try to grab the matrix + position of the transform:

navigator.getVRDisplays().then(x => console.log(x[0].stageParameters.sittingToStandingTransform))

and then compare it with a working session

johnshaughnessy commented 5 years ago

Not sure exactly what the problem is, but there's something suspicious about the sitting to standing matrix of the display not matching the sittingtostanding transform of the device:

navigator.getVRDisplays().then((d)=>console.log(d[0].stageParameters.sittingToStandingTransform))
VM532:1 Float32Array(16) [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1.1575560569763184, 0, 1]

AFRAME.scenes[0].systems.userinput.activeDevices.items[1].sittingToStandingMatrix
Matrix4 {elements: Array(16)}
elements: Array(16)
0: 1
1: 0
2: 0
3: 0
4: 0
5: 1
6: 0
7: 0
8: 0
9: 0
10: 1
11: 0
12: 0
13: 1.649999976158142
14: 0
15: 1
length: 16

navigator.getGamepads()[0].pose.position
Float32Array(3) [0.03126392140984535, -0.3653106391429901, -0.6155839562416077]

AFRAME.scenes[0].systems.userinput.activeDevices.items[1].pose.position
Vector3 {x: 1.8029647290328614, y: 1.6020006349444045, z: 5.922293372401389}
johnshaughnessy commented 5 years ago

The problem appears to be that we assume the sittingToStandingMatrix of the VRDisplay is going to match the sittingToStandingMatrix of the gamepad, and this does not seem to be the case.

https://github.com/mozilla/hubs/blob/master/src/systems/userinput/devices/oculus-touch-controller.js#L48

https://github.com/mozilla/hubs/blob/master/src/systems/userinput/devices/copy-sitting-to-standing-transform.js#L1

johnshaughnessy commented 5 years ago

Oh, scratch that previous comment. Gamepads don't report a sitting to standing matrix. What's happening here is that we are trying to sample the sittingToStandingMatrix of the VRDisplay before it is available, and never try to get it again. (In other words, displays[0] is undefined here: https://github.com/mozilla/hubs/blob/master/src/systems/userinput/devices/copy-sitting-to-standing-transform.js#L4)

This also explains why exiting and re-entering VR mode fixes the problem: The gamepads disconnect and reconnect and when they reconnect we reinitialize the device and by then the VRDisplay is ready.

johnshaughnessy commented 5 years ago

Solution is probably to change copy-sitting-to-standing-transform such that if no VRDisplay is present, it retries in a loop. (A better solution is to know exactly when the VRDisplay is made available, but I'm not sure when that is yet)

gfodor commented 5 years ago

nice one!

misslivirose commented 5 years ago

I put a P1 on this because I suspect it's possible that this is also the root cause with hands showing up in funky spots with the Valve Index too.

johnshaughnessy commented 5 years ago

Closing this issue because I think I fixed it in #1718. If we get another report of this let's re-open.

gfodor commented 4 years ago

Saw this again today on Quest. it does seem to be correlated with the very first session after powering on the headset.

joshmarinacci commented 4 years ago

Does still happen?