Troubleshooting
Find the problem you see, then check its causes in order.
Starting a Session
| Problem | Cause | Fix |
|---|---|---|
| VR or AR is never available, and the button to enter it never shows | The page isn't in a secure context | Serve it over HTTPS, or from localhost. See Testing on a Device |
| The page is in an iframe that doesn't allow XR | Add allow="xr-spatial-tracking" to the <iframe>. In debug builds, the engine logs a warning when it skips checking availability for this reason | |
| The graphics device uses WebGPU, in a browser that can't present WebGPU to a headset | Use WebGL 2. See Choosing a Graphics Device | |
| The device doesn't support the session type, such as AR on an Apple Vision Pro | See Platforms | |
The code checked isAvailable once, as the application started | The answer arrives asynchronously. Follow the available event. See Checking Availability | |
The application has no XR manager, so app.xr is null | Add options.xr = XrManager to the AppOptions of an application created with AppBase | |
| The session doesn't start when the button is selected | The session was requested outside the handler of a user action, such as after an await or from a timer | Call startXr, or fire the event that starts the session, in the click handler itself |
It asks for a reference space that the device doesn't support, such as bounded-floor | Start with local-floor. Pass a callback to startXr to see the error. See Reference Spaces | |
| A session is already running or starting | Only one session can run at a time. The callback is passed XR session is already started or XR session is already starting | |
| A feature such as plane detection is unavailable during the session | The session was started without the option that asks for it | Pass the option to startXr. The XrSession script starts sessions without options. See Options and Features |
| The device or the user didn't grant it | Check app.xr.session.enabledFeatures, and see Platforms |
In the Session
| Problem | Cause | Fix |
|---|---|---|
| Setting the camera's position or rotation has no effect | The headset sets the camera's local position and rotation every frame | Move the camera's parent, the rig. See The Camera and Its Rig |
| The user is too high, too low or inside the floor | The session uses local space, whose origin is at the user's head | Use local-floor, whose origin is on the floor |
| The rig isn't on the floor of the scene | Put the rig at the height of the floor. The XrSession script puts it at y = 0 when a session starts | |
| The user starts in a different place, or facing another way, from the page's view | The XrSession script moves the rig below the camera, facing where it faces | Place and turn the camera, before the session starts, where the user should start |
| The camera doesn't return to where it was after a session | Nothing restores it, unless the XrSession script is on the rig | Add XrSession, or save and restore the camera and rig yourself in start and end handlers |
| Objects disappear when brought close to the eyes | The camera's near clip distance is too large | Set nearClip to between 0.01 and 0.1 |
| The button that enters XR stays hidden after a session ends | Its end handler checks app.xr.active, which is still true while end handlers run | Show the button in the end handler without checking active, as Getting Started does. See Ending a Session |
| The application keeps running behind the system menu | It doesn't react to the session's visibility | Pause it on the visibility:change event. See Visibility |
Input
| Problem | Cause | Fix |
|---|---|---|
| No controllers or hands are drawn | Nothing draws them: the engine reports their poses, but doesn't draw models | Add the XrControllers script to the rig. See Controller Models |
XrControllers can't download the models | It loads them from a CDN, so the device needs internet access. Set its basePath attribute to host the models yourself | |
XrControllers was added during the session | It only draws the input sources that are added after it starts. Add it before the session starts. XrNavigation is the same | |
| Controllers are drawn in the wrong place | Their models aren't children of the rig, and are placed with local poses | Use world positions and rotations, getPosition() and getRotation(), or add the models under the rig. See Tracking Space |
getPosition() and getRotation() return null for a hand | Tracked hands have no grip pose | Use the poses of the hand's joints, such as its wrist. See Joints |
Reading a thumbstick gives undefined | The input source is a hand, or a controller without a thumbstick, and its gamepad leaves the axes out | Check the length of axes, or read it with ?? 0. See Buttons and Thumbsticks |
| Selecting a button or menu item also teleports the user | XrNavigation teleports at the end of every select on valid ground | Turn teleporting off while a menu is open or a ray points at the interface. See Teleporting and Menus |
| Teleports land behind walls, or fall through steps | The castRay function returns null for walls, so the arc carries on, or casts from where the last segment ended | See Landing on Your Geometry |
| A grabbed object stays behind, or shakes, when it has a rigid body | Physics moves dynamic bodies, and overrides the transform that your code sets | Make the body kinematic while it is held. See Throwing |
In AR
| Problem | Cause | Fix |
|---|---|---|
| The background is black or a color, not the real world | The camera clears to an opaque color, or a skybox is drawn | Give the camera a transparent clear color, new Color(0, 0, 0, 0), and hide the skybox layer. The XrSession script does both during AR sessions |
| Content placed on hit test results, planes or anchors is in the wrong place, or drifts as the user moves | These poses are in tracking space, and the rig has moved away from the scene's origin | Add the content as a child of the rig, and set its local position and rotation. See Tracking Space |
| The background turns opaque during an AR session in React | <Camera> sets the clear color from its clearColor prop each time it renders, over the transparent color that XrSession sets | Keep the component from rendering during the session, or give clearColor a transparent value during AR sessions. See Your First AR Scene |
| Hit tests return no results on a phone | The phone hasn't found any surfaces yet | Ask the user to move the phone slowly over the floor for a few seconds. See Starting a Hit Test |
| A controller's or a hand's hit test source returns no results | hitTestStart() uses hit tests for transient input, which WebXR only gives for transient input sources, such as taps | Test the ray against detected planes or meshes. See Hit Tests from Screen Taps |
Creating an anchor from a hit test result fails with XRFrame access outside the callback that produced it is invalid | The result belongs to an earlier frame, such as one kept for a later select | Create the anchor in the hit test source's result handler. See Creating Anchors |
Each anchor gets two objects, or the callback of create() is never called | In engine 2.24, an anchor from a hit test result, or restored, fires add twice, and create(position, rotation) doesn't call its callback when it succeeds | Follow anchors from hit test results, and restored anchors, from their callbacks, and others from add. See Creating Anchors |
| Light estimation is never available | It doesn't run until it's started | Call app.xr.lightEstimation.start() in the session's start handler. See Starting Light Estimation |
getDepth() always returns null | The session's depth sensing uses the GPU, as on a Meta Quest | Read the depth texture in a shader instead. See The Depth Texture |
| Virtual objects show in front of real objects that should hide them | Nothing hides them: the scene is drawn over the real world | Draw the room's meshes into the depth buffer, or use depth sensing. See Hiding Objects Behind Real Ones |
Performance
| Problem | Cause | Fix |
|---|---|---|
| The view is blurry, or text is hard to read | The session renders below the device's recommended resolution | Set maxPixelRatio to window.devicePixelRatio. See Resolution |
| The view judders or smears as the user looks around | Frames take longer than the headset's frame time | See Performance, and lower the frame rate or the resolution |
| Fixed foveation has no effect | The graphics device uses anti-aliasing with WebGL | Create the device with antialias: false. See Fixed Foveation |
See Also
- Testing and Debugging - Emulators, devices and remote debugging
- Sessions - The session lifecycle, reference spaces and the camera rig
- Troubleshooting in the User Interface section - For panels and buttons that don't respond in XR