Skip to content

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

@oeway

Description

@oeway

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions