immersive-web / webvr-polyfill

Use WebVR today, without requiring a special browser build.

Home Page:http://immersive-web.github.io/webvr-polyfill/examples/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when going into VR mode using Polyfill with Unity exporter

tbalouet opened this issue · comments

Description:

Trying an experience using the Mozilla's Unity exporter on mobile, there seems to be an error when entering the VR mode.
Example to test: http://adityabawankule.me/Unity/WebVR/Beach/index.html
Unity-to-webvr library: https://hacks.mozilla.org/2018/02/create-vr-on-the-web-using-unity3d/
Log of the error (Range error at the end)
screenshot from 2018-02-22 15-41-10

Result: it produces a distorted view of the experience, but everything's frozen and we have to leave the page.

Additional Information:
  • webvr-polyfill version: 0.9.36
  • Browser name/version/release channel: tested on Samsung Internet Browser and Chrome on Samsung S8
  • Operating System: Android 7.0

The recursion error leaves me the believe this isn't polyfill related -- does this work on native VR platforms (S8 on Chrome should be able to enable native WebVR)? I haven't dug into the Unity WebVR exporter yet, if this works on native WebVR I'll dig into it more!

Reading more in the exporter issues (MozillaReality/unity-webxr-export#113), it appears there may be different limits in Unity's exported JS

I was able to run this on Chrome 64 with native WebVR enabled successfully; sometimes did get an 'Uncaught RangeError: Array buffer allocation failed'.

Here's an image with more information on the recursion.

screenshot from 2018-02-23 09-52-20

It looks like webvr.js overwrites window.requestAnimationFrame with a function that calls VRDisplay's raf or a saved window.raf depending on if we're presenting or not. In polyfill land, the VRDisplay's raf ultimately calls window.requestAnimationFrame since we don't have a real VRDisplay, resulting in the recursion.

The fix here would be to cache the window.requestAnimationFrame in the polyfill, and could also be fixed by not overwriting window.raf in the Unity exporter. I suggest both! I'll make a fix for this.

Fixed in immersive-web/cardboard-vr-display@6f6a0c1, cardboard-vr-display@1.0.6 -- need to uplift and release in the polyfill, and will need to be added in exporter via MozillaReality/unity-webxr-export#113