facebookarchive / react-360

Create amazing 360 and VR content using React
https://facebook.github.io/react-360
Other
8.73k stars 1.23k forks source link

VrHeadModel.inVR() returns false while in VR mode #332

Closed 3hpibwalker closed 6 years ago

3hpibwalker commented 7 years ago

Description

This is a bug. On the Galaxy 7 and Galaxy 8, using the Chrome browser, when opening a ReactVR site, the site behaves as if the VrHeadModel.inVR() function is returning false. Tapping the "View in VR" button prompts with instructions to attach the phone to GearVR. Upon doing so, the site is displayed in VR mode, but behaves as if the VrHeadModel.inVR() function continues to return false (displaying components that only show up when inVR() returns false). The behavior also happens when browsing through the Carmel browser directly.

From the Oculus home, using "Browser" and then "View in VR" works as expected, behaving as if the VrHeadModel.inVR() is returning true.

Expected behavior

VrHeadModel.inVR() returns false when not in VR mode, and returns true when in VR mode.

Actual behavior

On Galaxy 7 and Galaxy 8, ReactVR enabled site behaves as if VrHeadModel.inVR() is returning false when in VR mode using both the Chrome and the Carmel browsers, but works as expected when using the Oculus browser and switching to VR mode from the VR home screen.

Reproduction

Sample and source code available on request. Reproduction described above.

Solution

It seems that lines 33 to 38 in VrHeadModel.js are not catching the events. The only testing we are able to do at this point is indirect observation, due to not having VR debugging tools to pause on the event handler or check the values of _inVR.

  RCTDeviceEventEmitter.addListener('onEnterVR', () => {
      this._inVR = true;
    });
    RCTDeviceEventEmitter.addListener('onExitVR', () => {
      this._inVR = false;
    });

Additional Information

andrewimm commented 7 years ago

This may have actually been fixed by the cleanup in 1db36de9c8d9179918fadd11045a25b38dae4eab, I'll see if I can confirm that later today.