← Back to release summary

WebXR enabledFeatures attribute

Category
Miscellaneous
Type
New or changed feature
Status
Enabled by default (Chrome 111)
Intent stage
Prepare to ship

Summary

Returns the set of features that were enabled for this XRSession as specified by XRSessionInit and the Implied Features required by the spec for the given mode/features. For a granted Session, this will contain all "requiredFeatures", but may be a subset of optionalFeatures. Most features have alternate ways to detect if they were granted; however, for some features the signal of whether or not a feature was enabled may tie closely with data for a feature just not being available "right now", rather than data not being available "ever". By querying enabledFeatures, you can determine if any helpful hints (e.g. to improve/start tracking) should be shown, or if a feature will never be supported in the current session. Future WebXR features may not have other signals to detect whether or not they were enabled, and would require querying this attribute.

Motivation

When requesting an XR Session, developers create an XRSessionInit dictionary. This dictionary has two main entries: requiredFeatures and optionalFeatures. These two lists represent XR features that a site either needs or would like to have available in a granted XR Session. While a developer can be assured that if a session is created all of the requested "requiredFeatures" are enabled, they are unable to determine which, if any, "optionalFeatures" were enabled. Some features, such as the bounded-floor reference space or hit-test, simply function when not enabled by just not returning poses when requested; however, there are other reasons why these might not return a pose either (e.g. if tracking is lost). This leaves developers without any clear way to know if a given feature is not reporting data due to something the user can fix, or if the feature is simply not supported by the hardware (or was simply rejected by the user), and thus will never report data. As the WebXR specification matures and new capabilities are added, it is possible that new features may lack even the ability for a developer to otherwise detect if it were enabled if the feature is truly "optional" (the currently being discussed "front facing camera" feature is an example of one such feature).

Standards & signals

Explainers: https://github.com/immersive-web/webxr/blob/main/explainer.md#feature-dependencies

View on chromestatus.com