AR Foundation - Camera Frame Rate defaulting to 30?

Hey there,

As title, after testing over two devices (Pixel 4 XL and Galaxy S20+), it appears I don’t have control over what frame-rate the camera defaults to, and subsequently what frame-rate my app runs at.

Things I’m currently using:

Application.targetFrameRate = 60;
ARSession.matchFrameRate = false;

ARSession.matchFrameRate appears to not have any effect, as far as I can tell.

The Pixel (I believe) has a default camera FPS of 60, subsequently my app runs at 60fps on the device. On the S20, however, while the device itself has the ability for the camera to run at higher frame-rates, the default is 30fps, and as a result - my app runs at 30.

AR Core evidently has a CameraConfig class to help with this - see: Hỗ trợ ARCore cho nhà phát triển Unity  |  Google for Developers, but this isn’t accessible within AR Foundation, as far as I can tell.

Is anyone able to give me an idea of what I could to here (if anything) to request a 60FPS from my devices’ camera, if it has the ability?

EDIT
Never mind, this may simply be an ARCore support limitation - as listed here ARCore supported devices  |  Google for Developers, only Pixel devices have 60fps support.

AR Foundation has an API for setting camera configuration:
https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.1/api/UnityEngine.XR.ARFoundation.ARCameraManager.html#UnityEngine_XR_ARFoundation_ARCameraManager_currentConfiguration

Here is an example of usage:

if (cameraManager.descriptor.supportsCameraConfigurations) {
    using (var configs = cameraManager.GetConfigurations(Allocator.Temp)) {
        foreach (var config in configs) {
            if (isPreferredConfig(config)) {
                try {
                    cameraManager.currentConfiguration = config;
                    break;
                } catch (Exception e) {
                    Debug.LogError("setting cameraManager.currentConfiguration failed with exception: " + e);
                }
            }
        }
    }
}

static bool isPreferredConfig(XRCameraConfiguration config) {
    throw new NotImplementedException("todo: determine if this camera configuration is preferred for your app");
}

Thanks for the pointer mate. Unfortunately, it appears my S20 is only reporting 30fps camera configurations - could this have something to do with 60 potentially being classed as a “high speed capture session”, and subsequently not reporting? CameraConstrainedHighSpeedCaptureSession  |  Android Developers ?

EDIT
Never mind, this may simply be an ARCore support limitation - as listed here https://developers.google.com/ar/discover/supported-devices, only Pixel devices have 60fps support.

is there any way to bypass that restriction, clearly S20 can handle 60fps

1 Like