@@ -84,18 +84,33 @@ public IEnumerator TestTimeIntegrationTest(int targetFrameRate, uint tickRate)
8484
8585 var framesToRun = 3d / frameInterval ;
8686
87+ var waitForNextFrame = new WaitForFixedUpdate ( ) ;
88+
8789 for ( int i = 0 ; i < framesToRun ; i ++ )
8890 {
89- yield return null ;
90- var capturedFrameRate = Time . captureFramerate ;
91+ // Assure we wait for 1 frame to get the current frame time to check for low frame rates relative to expected frame rates
92+ yield return waitForNextFrame ;
93+
94+ // Adjust the time tolerance based on slower than expected FPS
95+ var currentFPS = 1.0f / Time . deltaTime ;
96+ var fpsAdjustment = 1.0f ;
97+ var currentAdjustment = additionalTimeTolerance ;
98+ if ( currentFPS < targetFrameRate )
99+ {
100+ // Get the % slower and increase the time tolerance based on that %
101+ var fpsDelta = targetFrameRate - currentFPS ;
102+ fpsAdjustment = 1.0f / fpsDelta ;
103+ currentAdjustment += additionalTimeTolerance * fpsAdjustment ;
104+ }
105+
91106 UpdateTimeStates ( networkManagers ) ;
92107
93108 // compares whether client times have the correct offset to server
94- m_ServerState . AssertCheckDifference ( m_Client1State , tickInterval , tickInterval , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
95- m_ServerState . AssertCheckDifference ( m_Client2State , 0.2 , 0.1 , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
109+ m_ServerState . AssertCheckDifference ( m_Client1State , tickInterval , tickInterval , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
110+ m_ServerState . AssertCheckDifference ( m_Client2State , 0.2 , 0.1 , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
96111
97112 // compares the two client times, only difference should be based on buffering.
98- m_Client1State . AssertCheckDifference ( m_Client2State , 0.2 - tickInterval , ( 0.1 - tickInterval ) , tickInterval * 2 + frameInterval * 2 + additionalTimeTolerance ) ;
113+ m_Client1State . AssertCheckDifference ( m_Client2State , 0.2 - tickInterval , ( 0.1 - tickInterval ) , tickInterval * 2 + frameInterval * 2 + currentAdjustment ) ;
99114 }
100115 }
101116
0 commit comments