Self-hosting and WebVR in Chrome/Android

This post is relevant only to the Shapespark users who host scenes on their own and want to take advantage of the native WebVR support in Chrome on Android. Scenes on the Shapespark hosting have native WebVR support enabled in Chrome on Android by default.

If you load scenes from your own hosting you might have noticed that the frame rate in VR mode in Chrome on Android is lower than if the scenes were loaded from the Shapespark hosting. This is because Chrome on Android still treats WebVR as an experimental feature and to enable native WebVR support it requires one of the following:

  • The person viewing the scene has to explicitly enable the WebVR flag in the browser settings: chrome://flags#enable-webvr
  • The hosting server has to return a special WebVR Origin Trial token for the index.html file of the scene.

Otherwise, the VR mode is emulated which results in lower frame rate.

In most of the cases it’s more suitable to use the WebVR Origin Trial token on the server to enable native WebVR without requiring additional action from the viewing person (this is what Shapespark hosting does). Such a token has to be requested from Google for a particular site’s origin (domain). The token is valid for a specified amount of time, so it has to be periodically renewed.

The token can be placed in the index.html files of a hosted scene as:

<meta http-equiv="origin-trial" content="OBTAINED-TOKEN">

or it can be returned as an Origin-Trial HTTP response header for the index.html file.

For example, if Apache HTTP Server is used on the hosting the following rule can be placed in the .htaccess file of the scene directory (or in the case of multiple scenes sharing the same parent directory it can be placed in the .htaccess file of the parent directory):

<Files "index.html">
  Header set Origin-Trial OBTAINED-TOKEN
</Files>

For more information consult: Chrome for Android • WebVR Rocks