How Safari on visionOS Supports the WebXR Device API
This article provides a comprehensive overview of how the Safari web browser on Apple’s visionOS supports the WebXR Device API to deliver immersive virtual reality (VR) and augmented reality (AR) experiences. It covers the supported WebXR session modes, the unique privacy-preserving interaction model for eye and hand tracking, the graphics rendering pipeline, and how developers can utilize these features to build spatial web applications for the Apple Vision Pro.
Supported WebXR Session Modes
Safari on visionOS supports the standard WebXR Device API, allowing web developers to create cross-platform spatial content. While originally hidden behind experimental feature flags in visionOS 1, WebXR is enabled by default starting in visionOS 2.
Safari supports two primary immersive session modes:
immersive-vr: This mode completely replaces the user's real-world surroundings with a fully rendered 3D virtual environment from the web browser.immersive-ar: This mode composites the web page's 3D graphics directly over the Apple Vision Pro’s real-world passthrough video feed. The background of the WebGL canvas is rendered as transparent, allowing virtual objects to exist in the user's physical space.
Inline sessions (inline), which render 3D content inside
a standard 2D web page window before entering an immersive state, are
also fully supported.
The Interaction Model: Gaze and Pinch
The most unique aspect of WebXR on visionOS is how it handles user input. Unlike traditional VR headsets that rely on physical handheld controllers, the Apple Vision Pro relies on eye tracking (gaze) and hand gestures (pinch).
To protect user privacy, visionOS does not expose raw eye-tracking
data to websites. A web application cannot see where the user is looking
in real-time. Instead, Apple collaborated with the W3C Immersive Web
Working Group to introduce a new WebXR input mode called
transient-pointer.
Here is how the transient-pointer works during a WebXR
session:
- System-Level Gaze: The user looks at a virtual object, and the operating system knows the gaze direction, but the web page does not.
- Pinch Activation: When the user pinches their thumb
and index finger together, the
transient-pointeris dynamically created. - Raycasting: At the exact moment of the pinch, Safari sends an input source to the WebXR application. The target ray originates from the user's head and points directly at the spot the user was looking at when the pinch began.
- Release: While the user holds the pinch, they can move their hand to drag or manipulate the object. Once they release the pinch, the input source is destroyed, and the website loses tracking data until the next pinch occurs.
Direct Hand Tracking and Controllers
For experiences that require direct physical interaction—such as
pushing virtual buttons or using two-handed gestures—the
transient-pointer is often not enough. To solve this,
Safari on visionOS also supports the WebXR Hand Input Module.
When a user enters an immersive session, the browser can request explicit permission to access skeletal hand data. If the user grants this permission, the WebXR API provides the exact 3D positions and orientations of 25 joints per hand on every frame. This allows developers to render custom virtual hands and enable direct touch interactions with virtual objects.
Additionally, if a user has paired standard Bluetooth gamepads or supported spatial controllers with their Vision Pro, Safari maps these to the standard WebXR Gamepad module automatically.
Rendering and Performance
WebXR in Safari relies on WebGL (and increasingly WebGPU) to render 3D graphics. When an immersive session starts, Safari requests a stereoscopic rendering layer from the WebXR API. The developer's code renders two views—one for the left eye and one for the right eye—to a single shared framebuffer.
To maintain the high resolution and 90Hz+ refresh rates required by the Apple Vision Pro, visionOS handles heavy graphical optimizations at the system level. Once the WebXR application submits its rendered frame to the browser, the visionOS compositor applies system-level dynamic foveated rendering and motion reprojection to ensure the experience remains smooth and comfortable for the user, reducing the likelihood of motion sickness.
Privacy and Security Architecture
Because WebXR accesses sensitive hardware data, Safari enforces strict security protocols on visionOS:
- HTTPS Requirement: WebXR APIs will only function in secure contexts (HTTPS).
- User Intent: A website cannot automatically launch into a VR or AR session on page load. The session must be triggered by an explicit user action, such as looking at and tapping a 2D "Enter VR" button on the webpage.
- System Override: Users can exit any WebXR experience instantly by pressing the Digital Crown on the headset, preventing malicious websites from trapping users in a virtual environment.
- Passthrough Protection: During an
immersive-arsession, the website never gains access to the camera feed. The website only renders graphics onto a transparent layer, and the operating system merges those graphics with the camera feed locally on the device.