Framerate Optimization for Mixed Reality Apps

Mixed reality apps are more resource intensive than a typical mobile app due to their processing and rendering load. Thermal considerations are especially important for apps that run on digital eyewear. If the device becomes too hot, its operating system will reduce the framerate of your app in order to avoid overheating.

For this reason, the Vuforia SDK provides an API that enables you to dynamically adjust the framerate of your digital eyewear app. This API enables you to balance runtime performance against computational load and power consumption, giving you control of your app's performance characteristics.

Note: The recommended framerate API is only intended for use on digital eyewear. It is not needed on mobile devices, which can use the Camera Device Mode API to request performance targets.

Use the table below for the recommended settings for each device. The general rule is that in VR the rendering has to be at 60fps for a smooth viewing experience while in AR, rendering can be at 30fps or at 60fps depending on the device. Please note that these are only recommended settings. If you have very short AR/VR experiences (about 2-3 minutes), then it is certainly possible to render at 60fps in both AR and VR modes.
Eyewear AR/VR
Mode
Target Render
FPS
Use these hints in
getRecommendedFps(hints);
Gear VR VR 60 NO_VIDEOBACKGROUND
Gear VR AR 60 NONE
Cardboard VR 60 NO_VIDEOBACKGROUND | FAST
Cardboard AR 30 NONE
BT-200 AR 30 NO_VIDEOBACKGROUND
ODG R-6 AR 30 NO_VIDEOBACKGROUND
Mobile Devices AR/VR
Mode
Target Render
FPS
Use these hints in
getRecommendedFps(hints);
Mobile Devices AR 30 NONE
Mobile Devices AR 60 FAST

Implementation

The Vuforia API provides the getRecommendedFps and setTargetFps methods to obtain and set a recommended render framerate based on your app's rendering and performance requirements. The getRecommendedFPS method accepts one or more hints as arguments.

To set a target framerate, call these methods when initializing the app, and whenever the app transitions between AR and VR modes. Review the Digital Eyewear samples to see how and where these methods should be called.

There are 5 hint flags available for configuring the target FPS recommendation:
  • FAST ~ the fastest framerate available for the device and firmware combination
  • NO_VIDEOBACKGROUND ~ indicates that the current mode does not render a video background
  • NONE ~ no hint is applied
  • POWER_EFFICIENCY ~ the framerate should be adjusted to reduce power consumption
C++ Example - sets the recommended FPS to NONE unless running in an optical see-through device
private boolean configureRenderingFrameRate()
    {             
        // In this example we selected the default preset hint for best Mobile AR Experience
        // See website documentation for more information on the rendering hint modes 
        // relevant to your AR experience.
        int myRenderingOptions = Renderer.FPSHINT_FLAGS.FPSHINT_NONE;	
     
        // Optical see-through devices don't render video background
        if (Eyewear.getInstance().isDeviceDetected() &&
            Eyewear.getInstance().isSeeThru())
        {
            myRenderingOptions = Renderer.FPSHINT_FLAGS.FPSHINT_NO_VIDEOBACKGROUND;
        }
        
        // Retrieve recommended rendering frame rate best on currently configured/enabled vuforia features
        // and selected application hint
        int vuforiaRecommendedFPS =  Renderer.getInstance().getRecommendedFps(myRenderingOptions);
     
        // Use the recommended fps value computed by Vuforia
        if (!Renderer.getInstance().setTargetFps(vuforiaRecommendedFPS))
        {
            Log.e(LOGTAG,"Failed to set rendering frame rate to: " + vuforiaRecommendedFPS + " fps");   
            return false;
        }
        else
        {
            Log.i(LOGTAG,"Configured frame rate set to recommended frame rate: " + vuforiaRecommendedFPS + " fps");        
        }   
        return true;
    }

Unity Example in TransitionManager.cs

void Update () 
    {
        // We need to check if the video background is curently enabled
        // because Vuforia may restart the video background when the App is resumed
        // for example, if ARMode and mCurrentARMode are both false because we paused while in VR,
        // at resume time, the video background might get restarted beind the hood by Vuforia (despite we were in VR)
        bool isVideoCurrentlyEnabled = IsVideoBackgroundRenderingEnabled();

        bool ARMode = (mTransitionFactor <= 0.5f);
        if ((ARMode != mCurrentARMode) || (ARMode != isVideoCurrentlyEnabled))
        {
            mCurrentARMode = ARMode;

            // Query Vuforia for a target frame rate and set it in Unity:
            int targetFPS =
                VuforiaRenderer.Instance.GetRecommendedFps(ARMode ? VuforiaRenderer.FpsHint.NONE : VuforiaRenderer.FpsHint.NO_VIDEOBACKGROUND);
            // by default, we use Application.targetFrameRate to set the recommended frame rate.
            // Cardboard does not use vsync, and OVR explicitly disables it. If you use vSync in your quality settings, you should 
            // also set the QualitySettings.vSyncCount according to the value returned above.
            // e.g. if targetFPS > 50 --> vSyncCount = 1; else vSyncCount = 2;
            Application.targetFrameRate = targetFPS;

...