Switching between WebXR and XrHands crashes game

Howdy,

I’m using code similar to the template project for switching between XR modules, but I’m getting errors when doing so. Is there anything I can do to get this working? I really need to for a client project XD

Code:

// Tracking system management
enableImageTracking() {
  if (!this.isImageTrackingEnabled) {
    console.log('🔍 Enabling image tracking')

    // Ensure hand tracking is removed first
    if (this.isHandTrackingEnabled) {
      this.sceneEl.removeAttribute('xrhand')
      this.isHandTrackingEnabled = false
    }

    this.sceneEl.setAttribute('xrweb', {
      allowedDevices: 'any',
    })
    this.isImageTrackingEnabled = true
  }
}

enableHandTracking() {
  if (!this.isHandTrackingEnabled) {
    console.log('👋 Enabling hand tracking')

    // Ensure image tracking is removed first
    if (this.isImageTrackingEnabled) {
      this.sceneEl.removeAttribute('xrweb')
      this.isImageTrackingEnabled = false
    }

    this.sceneEl.setAttribute('xrhand', {
      allowedDevices: 'any',
      cameraDirection: 'back',
      mirroredDisplay: false,
      enableWrists: true,
    })
    this.isHandTrackingEnabled = true
  }
}

Error Logs:

[RuntimeError] XR caught an error; stopping. TypeError: undefined is not an object (evaluating ‘o.processCpuInput.frameStartResult’)
at (anonymous) bundle.tracing.replay.min.js
at onException xrextras.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at IA xr-simd-27.4.8.427.js
at tick xr-simd-27.4.8.427.js
at tick 8frame-1.4.1.min.js
at render 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at r 8frame-1.4.1.min.js
at (anonymous) xr-simd-27.4.8.427.js
at sentryWrapped bundle.tracing.replay.min.js
18:27:37
▼ [XR] Pause cannot be called at this time.
at (anonymous) bundle.tracing.replay.min.js
at lA xr-simd-27.4.8.427.js
at onException xrextras.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at IA xr-simd-27.4.8.427.js
at tick xr-simd-27.4.8.427.js
at tick 8frame-1.4.1.min.js
at render 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at r 8frame-1.4.1.min.js
at (anonymous) xr-simd-27.4.8.427.js
at sentryWrapped bundle.tracing.replay.min.js
18:27:37
▼ XR threw an exception TypeError: undefined is not an object (evaluating ‘o.processCpuInput.frameStartResult’)
at (anonymous) bundle.tracing.replay.min.js
at onException xr-simd-27.4.8.427.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at IA xr-simd-27.4.8.427.js
at tick xr-simd-27.4.8.427.js
at tick 8frame-1.4.1.min.js
at render 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at r 8frame-1.4.1.min.js
at (anonymous) xr-simd-27.4.8.427.js
at sentryWrapped bundle.tracing.replay.min.js
18:27:37
▼ @https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:78608
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:76694
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:79495
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:76694
IA@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:79605
tick@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:249400
tick@https://cdn.8thwall.com/web/aframe/8frame-1.4.1.min.js:1:431868
render@https://cdn.8thwall.com/web/aframe/8frame-1.4.1.min.js:1:432366
@https://cdn.8thwall.com/web/aframe/8frame-1.4.1.min.js:1:1239080
@https://cdn.8thwall.com/web/aframe/8frame-1.4.1.min.js:1:876887
r@https://cdn.8thwall.com/web/aframe/8frame-1.4.1.min.js:1:593080
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:59934
sentryWrapped@https://browser.sentry-cdn.com/8.55.0/bundle.tracing.replay.min.js:2:67246
at (anonymous) bundle.tracing.replay.min.js
at onException xr-simd-27.4.8.427.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at IA xr-simd-27.4.8.427.js
at tick xr-simd-27.4.8.427.js
at tick 8frame-1.4.1.min.js
at render 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at (anonymous) 8frame-1.4.1.min.js
at r 8frame-1.4.1.min.js
at (anonymous) xr-simd-27.4.8.427.js
at sentryWrapped bundle.tracing.replay.min.js
18:27:37
▼ XR threw an exception TypeError: null is not an object (evaluating ‘A.PIXEL_PACK_BUFFER’)
at (anonymous) bundle.tracing.replay.min.js
at onException xr-simd-27.4.8.427.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at e xr-simd-27.4.8.427.js
18:27:38
▼ Y@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:75713
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:80792
nA@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:81299
@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:18:85034
e@https://cdn.8thwall.com/xr-simd-27.4.8.427.js:1:1935
at (anonymous) bundle.tracing.replay.min.js
at onException xr-simd-27.4.8.427.js
at forEach [native code]
at K xr-simd-27.4.8.427.js
at (anonymous) xr-simd-27.4.8.427.js
at e xr-simd-27.4.8.427.js

I can take a look. Can you land your changes and share the project with the support workspace?

1 Like

Ah, ok I resolved it.

Trying to switch from image targets to hand tracking inside a callback being executed by image targets was probably not the smartest idea. I added a timeout within the callstack so that it can swap (hopefully) after the image targets code as finished.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.