XRSession: depthUsage property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The read-only depthUsage property of an immersive-ar XRSession describes which depth-sensing usage is used.

Value

This property can return the following values:

cpu-optimized

The depth data is intended to be used on the CPU; see the XRCPUDepthInformation interface.

gpu-optimized

The depth data is intended to be used on the GPU; see the XRWebGLDepthInformation interface.

Examples

To request the desired usage method, you need to specify a usagePreference when requesting a session using XRSystem.requestSession(). Here, the caller is able to handle both CPU- and GPU-optimized usage. The order indicates preference for CPU:

js
navigator.xr.requestSession("immersive-ar", {
  requiredFeatures: ["depth-sensing"],
  depthSensing: {
    usagePreference: ["cpu-optimized", "gpu-optimized"],
    formatPreference: ["luminance-alpha", "float32"],
  },
});

To check which usage was selected by the user agent, you can call the depthUsage property:

js
console.log(session.depthUsage); // either "cpu-optimized" or "gpu-optimized"

Specifications

Specification
WebXR Depth Sensing Module
# dom-xrsession-depthusage

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
depthUsage
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.