Search Unity

Bug OnDemandRendering causes framerate to double after switching applications

Discussion in 'Android' started by jfouk, Apr 16, 2021.

  1. jfouk

    jfouk

    Joined:
    Dec 29, 2019
    Posts:
    5
    Hello,

    I'm trying to use OnDemandRendering to lower my effective framerate during periods of my game where I don't need to be running at 60 fps. It works well for the most part, until I switch to another application on my phone, and switch back to the game. It seems like my effective framerate is almost doubled, instead of halved afterwards.

    I tried switching the renderInterval back to 1 when I lose application focus, but the same thing happens. Anyone else run into this problem before?

    I've attached a gif of normal behavior (on the left) and the error behavior (on the right).

    Here's the relevant code.

    Code (CSharp):
    1.     private void OnApplicationFocus(bool focus)
    2.     {
    3.         // if we lose focus
    4.         if ( !focus)
    5.         {
    6.             currentFrameInterval = OnDemandRendering.renderFrameInterval;
    7.             OnDemandRendering.renderFrameInterval = 1;
    8.         }
    9.         else
    10.         {
    11.             // reset to the current frame interval
    12.             OnDemandRendering.renderFrameInterval = currentFrameInterval;
    13.         }
    14.     }
    15.  
    onDemandRendering.gif onDemandRenderingDoubleSmall.gif
     
  2. myungjun

    myungjun

    Joined:
    Oct 5, 2015
    Posts:
    1
    i have the same issue

    unity version :2020.3.15f2, 2020.3.37f1

    device: ios, android