Closed Bug 1397397 Opened 7 years ago Closed 7 years ago

vrdisplayconnect / vrdisplaydisconnect not firing on Vive / OpenVR

Categories

(Core :: WebVR, defect)

55 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: dmarcos, Assigned: daoshengmu)

References

Details

Attachments

(1 file)

On Firefox 55 and running https://webvr.info/samples/00-hello-webvr.html I'm not able to trigger vrdisplayconnect / vrdisplayconnect when plugging / unplugging an HTC Vive. I tried multiple combinations of steps:

1. Open Firefox with OpenVR running and plug / unplug headset.
2. Close OpenVR and Firefox. Open Firefox and plug / unplug headset.
3. Reboot machine, Open Firefox, plug / unplug headset.

None of the steps above seem to help to trigger the event.
I'm having a similar issue. I actually do get vrdisplaydisconnect, but not vrdisplayconnect.

I haven't tried unplugging the headset - just exiting and starting SteamVR. If I exit SteamVR while Firefox is running, vrdisplaydisconnect fires as SteamVR begins its process of shutting down. As soon as it exits, if Firefox is still open, SteamVR will restart again, but there is no vrdisplayconnect event.

If I start without SteamVR running and then navigate to a WebVR site in Firefox, SteamVR will open by itself but there is no event fired.
Diego, I just did a bit more testing, and the issue with not detecting the unplugging/plugging of the device may be with SteamVR. When I unplug my device, SteamVR doesn't seem to recognize that I've done so. It just reports that it's lost tracking.

In the last couple months, I've found SteamVR's behavior to become rather wonky in general.
Brian, Thanks for the additional info. Today I tested with Rift and the event fires reliably if SteamVR is not running simultaneously to the Oculus runtime. When SteamVR initializes automatically after connecting the Rift, the events are not dispatched to Firefox. If I kill the SteamVR process and reload Firefox I see the events being fired reliably.
I can help this.
Assignee: nobody → dmu
It looks like VR_IsHmdPresent() is no longer can be the condition for detecting VRDisplay connected/disconnected. Besides, VR_IsHmdPresent() is weird for me, because it always return true, no matter we have disconnected with the HMD or terminating SteamVR already.

The more correct way for detecting connected/disconnected events in OpenVR should use IsTrackedDeviceConnected() instead of VR_IsHmdPresent(), and it also has VREvent_TrackedDeviceActivated and VREvent_TrackedDeviceDeactivated events for polling.

Currently, I track the state of VRDisplayConnected by polling events instead of checking it IsTrackedDeviceConnected(). Both of the approaches are good. There is no preference.
Comment on attachment 8905818 [details]
Bug 1397397 - Detect vrdisplayconnect/vrdisplaydisconnect events with IsTrackedDeviceConnected() in OpenVR;

https://reviewboard.mozilla.org/r/177626/#review182930

This LGTM, Thanks!
Attachment #8905818 - Flags: review?(kgilbert) → review+
Pushed by dmu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/728c1c579a4c
Detect vrdisplayconnect/vrdisplaydisconnect events with IsTrackedDeviceConnected() in OpenVR; r=kip
https://hg.mozilla.org/mozilla-central/rev/728c1c579a4c
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Wow, very fast turn-around. Thanks for that. I'll try and test it today, assuming it's made its way into Nightly by now.
I'm getting the vrdisplayconnect event now, and it seems pretty reliable.

As before, if I disconnect the headset but keep SteamVR open, the browser doesn't seem to notice, and SteamVR just acts like it lost tracking. If I exit SteamVR, I get the disconnect event, and then SteamVR restarts itself again with the connect event firing again. So, awesome!

However, during the time that SteamVR is restarting, the browser locks up. I wonder, is IsTrackedDeviceConnected() a blocking call that might be taking a long time to return while that's happening?
(In reply to brian from comment #11)
> I'm getting the vrdisplayconnect event now, and it seems pretty reliable.
> 
> As before, if I disconnect the headset but keep SteamVR open, the browser
> doesn't seem to notice, and SteamVR just acts like it lost tracking. If I
> exit SteamVR, I get the disconnect event, and then SteamVR restarts itself
> again with the connect event firing again. So, awesome!
> 
I expect it can receive vrdisplayconnect/vrdisplaydisconnect when SteamVR is running. When SteamVR is existed, we will receive a vrdisplaydisconnect. However, after SteamVR restarts itself, we can't recover our tracking state and receive the vrdisplayconnect automatically because Firefox still have chance to be unresponsive.


> However, during the time that SteamVR is restarting, the browser locks up. I
> wonder, is IsTrackedDeviceConnected() a blocking call that might be taking a
> long time to return while that's happening?

I have confirmed it with FF Nightly 0904 build, it is already happened. So, I think it is not the real reason.
You need to log in before you can comment on or make changes to this bug.