Access to the feature "vr" is disallowed by feature policy

chrome
viewer-api
vr

(Snicklefritzal) #1

I am struggling to find the cause of DOM Exception I have recently run into while building a javascript web app using the Sketchfab api. The error comes from the following which I believe is code generated by the API.

init:function(){
    if(navigator.getVRDisplays){
         var e=this;navigator.getVRDisplays().then(function(t){
              t.length>0&&(e._hmd=t[0],e._frameData=new 
              window.VRFrameData,r.log("Found a VR display"), 
              e._viewer.setVRDisplay(e._hmd))
         })
    }
}

To my knowledge this error started happening when I moved a lot of my user data from one drive to another, the application runs fine on a similar machine where all program data and code is on one drive.

I'm running a local python server using py -m http.server 8080, my initial thought was that I was causing some kind of cross-domain scripting error. I'm not trying to use any VR features so this is particularly frustrating. The app appears to work as intended on the live site, this problem only occurs when launching from localhost.

Here is my launch.json file

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceRoot}"
        }
    ]
}

#2

Hmm weird. Can you share a link to the live site and/or your code related to the Sketchfab API?


(Snicklefritzal) #3

I believe the problem is specifically related to the chrome debugger extension for vs code, a promise rejection is thrown up which is where the error occurs. According to the github commits for the extension, some changes were made to how promises were handled so I imagine that's why it just started happening (likely when I updated the extension).

I'm avoiding the error for now by launching through node webkit with the "--remote-debugging-port=9222" argument. So yeah that's all I've got on this particular issue.


#4

Are you using the WebVR API Emulation extension or anything like that?


(Snicklefritzal) #5

Nope, I'm not interested in any of the vr features really.


#6

Hmm... maybe @nehon has an idea?


(Klaasnienhuis) #7

@james we're now dealing with the same issue. We're developing our sites on localhost as well (I'm using mamp)

This is the error we're getting: Uncaught (in promise) DOMException: Access to the feature "vr" is disallowed by feature policy.

In our case we're not using vr features and our embedding code hasn't changed for a long time.


(Stephomi) #8

@klaasnienhuis https://developers.google.com/web/updates/2017/09/webvr-origin-trial-chrome-62

Use of WebVR is restricted in cross-origin iframes. If you intend for embedded cross-origin iframes to be able to use WebVR, add the attribute allow="vr" to the iframe tag

allowvr should probably be allow="vr" now.
(not sure about firefox though, these iframe things are very badly documented and not really official)


(Klaasnienhuis) #9

Hi @stephomi that helped in chrome indeed. Haven't checked firefox yet.

Perhaps related, all ui controls appear in our iframes. We haven't touched these settings for a while but now I'm struggling to find the settings to hide all ui stuff. This is also happening on live sites which is not what we'd expect: https://configure.zodiac-nautic.com/. All these accounts are biz accounts.

Do you have an idea how we can fix this?


(Stephomi) #10

I think we have a bug on this subject (ui_controls, etc options not working) but we have a fix coming soon (in an hour or so if everything goes smoothly)


(Klaasnienhuis) #11

Looking forward to it! Thanks for the quick response