itk-vtk-viewer icon indicating copy to clipboard operation
itk-vtk-viewer copied to clipboard

Access to the feature "xr" is disallowed by permissions policy.

Open oeway opened this issue 3 years ago • 0 comments

When running the viewer in a sandboxed iframe it triggers error from the following code:

if (
      navigator.xr !== undefined &&
      navigator.xr.isSessionSupported('immersive-vr')
    ) {
      publicAPI.invokeHaveVRDisplay();
    }

The error is:

Uncaught (in promise) DOMException: Failed to execute 'isSessionSupported' on 'XRSystem': Access to the feature "xr" is disallowed by permissions policy.
    at QO.e.get3DContext (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1685856)
    at QO.e.initialize (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1684512)
    at QO.e.buildPass (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1684380)
    at e.apply (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1593961)
    at e.traverse (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1593820)
    at R_.e.traverse (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1656922)
    at QO.e.traverseAllPasses (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1701435)
    at u (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1561585)
    at e.render (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1570889)
    at e.initialize (https://kitware.github.io/itk-vtk-viewer/app/itkVtkViewer.js:2:1562143)

I think we need to add a try catch statement to prevent this error.

You can reproduce it with this: https://jupyter.imjoy.io/lab/index.html?load=https://gist.github.com/oeway/391b4352ea57b5682366ce3dc2fa9174&open=1

oeway avatar Jul 26 '22 23:07 oeway