Skip to content

OpenGL RenderWindow in sandboxed iframe console error #2537

@PaulHax

Description

@PaulHax

High-level description

When using OpenGL RenderWindow in a iframe (without xr-spatial-tracking feature policy?) get this error on first render:

Uncaught (in promise) DOMException: Failed to execute 'isSessionSupported' on 'XRSystem': Access to the feature "xr" is disallowed by permissions policy.
    at vtkOpenGLRenderWindow (webpack-internal:///./node_modules/vtk.js/Sources/Rendering/OpenGL/RenderWindow/index.js:221:75)

Steps to reproduce

Use vtk.js in "sandboxed" iframe

<iframe
  id="inlineFrameExample"
  title="Inline Frame Example"
  width="300"
  height="200"
  src="./viewer.html"
  sandbox="allow-scripts"
>
</iframe>

https://codesandbox.io/s/volume-rendering-bounds-forked-846gd7?file=/index.html:119-304

Expected behavior

No XR related errors unless I opt into trying to activate XR.

Environment

  • vtk.js: 25.4
  • OS: Linux
  • Browser: Chrome 103

Reported here:

Kitware/itk-vtk-viewer#534

Approach?

Looks like xr.isSessionSupported returns a Promise, so maybe something more like this:

if (navigator.xr) {
    navigator.xr
      .isSessionSupported('immersive-vr')
      .then(isSupported => {
        isImmersiveVrSupported = isSupported
      })
      .catch(error => {
        if (error.name !== 'SecurityError') {
          throw error
        }
      })
  }

Or remove this feature and lift this to user responsibility. I'm not seeing in repo use of HaveVRDisplay event.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions