GetAvailableFeatures returning features that are not compatible in Android's Chrome

I was very exciting implementing an AR view with plane detection to finally realise that this funcionality is not working in Chrome for Android since feb 2023 aprox. I hope Google provides this funcionality again soon, as I think it has amazing posibilities. (Using Chrome for Android version 122 btw)

The question I have is related to checking if a feature is available on the current device.

First I tried to use WebXRFeaturesManager.GetAvailableFeatures(), but it returns a list containing ‘xr-plane-detection’. Then when I call enableFeature it would return an error as it’s not compatible.

So I when to github and started browsing Babylon’s codebase.

My final implementatión is:

  1. Enable a feature as optional:
const xrPlaneDetector = featuresManager.enableFeature(
            false /** This specifies that it's an optional feature **/
  1. Check if this feature is compatible:

So my question is, why does GetAvailableFeatures returns features that are not available? Is it a chrome bug, babylonjs bug or I didn’t understand the porpose of this method?

Sorry for the confusion here! A few things:

  1. GetAvailableFeatures refers to the features that are enabled in the feature manager. Any feature can be activated and ready to be used, independent of your system support for it.
  2. isCompatible can only check if your environment holds the needed objects/classes/methods to run the feature. it is not fail-safe, as in certain cases the classes are there, but the system won’t support it.
  3. To avoid fingerprinting, the only way to actually know if your device supports something is entering a session while requesting the feature. Babylon does it for you under the hood. If you define a feature as optional, entering the session won’t fail, but it does not 100% mean that the feature is active.

To check if your system supports a certain feature you can do one of two things - after entering a session, you can check if the feature is attached to the session. Enabled !== Attached. The feature has a flag that will show you if it is attached or not. The other way is to check the enabledFeatures array on the session (which is also available in the WebXRSessionManager). This array is populated after entering a session and will hold all of the XR-native features that were enabled in this session. The attached feature uses this array as well, so you can use either one of them. A small note - the vision pro does not support this array. But then again, it also does not support AR, so Hurrah Apple!

1 Like

Thank you for such a good explanatacion I will check my implementation an check if features are attached instead of isCompatible.