The FPS displayed in UnrealInsights is unstable.

Why is the fixed rate processing function UpdateTimeAndHandleMaxTickRate executed before Engine::Tick?It causes the FPS displayed in UnrealInsights to be unstable. In my case, the MaxTickRate of DS is 30, but Insights shows that it completely fails to reach 30FPS and is extremely unstable.

Where is this “MaxTickRate” setting? What’s DS? Can you confirm you don’t have “Use Fixed Frame Rate” checkbox checked as this doesn’t behave like most people think it’s supposed to. Your framerate appears to be 30 fps based on the 4 frames shown in your screenshot. What’s unstable about it?

Sorry, I have made a mistake, the MaxTickRate just is Server Fixed FPS shown in Editor Preferences → Play → Server.
DS stands for Dedicated Server.
I’m sure that UseFixedFrameRate is enabled and the FixedFrameRate is set to 30, meaning each frame should theoretically take approximately 33ms. However, this target frame time is not consistently achieved in the screenshot.

I mentioned above that you need to ensure that is OFF. Unchecked.

UseFixedFrameRate is for debugging only. What it does is give you a constant DeltaTime in your tick functions. But the framerate is not affected. So it’s unclear how you even got near 30 fps unless they changed the behavior recently. Also, even if it did give a constant frame rate, each frame still wouldn’t take exactly the same amount of time.

To set a constant frame rate, you should use t.MaxFPS or set it in your UGameUserSettings class. But even that’s not gonna give you 33ms per frame. It’ll only average it out. I think if you have vsync on, it’ll try to stay under 33ms, but even then there’s no guarantee.

Also, setting a max fps will affect frames that take LESS than 33ms, not those that take more. If a frame takes more time to render, then you have to wait. There’s just no way around it. If you uncap your FPS and it still draws at 28 fps, setting max fps to 30 isn’t going to make it go faster. Said plainly, if your game runs at 120 fps, you can set max fps and lower it, but it won’t lower the time it takes your low 1% to render if those happen to take more than 33ms for example.

Thanks for your reply, I disabled UseFixedFrameRate and am using t.MaxFPS to limit the max frame rate, however the issue still remains.

I have checked the Unreal Engine source code, it sleeps for a calculated WaitTime (intended to achieve the fixed frame rate) before calling Engine::Tick. However the WaitTime depons on previous frame’s tick time, is it correct?

For example:
Frame 1, Engine::Tick takes 10ms to execute.
Frame 2, calculating WaitTime based on previous frame’s tick time, in this case, WaitTime is 23ms(t.MaxFPS=30, 33 - 10 = 23), and sleeping for 23ms.
Frame 2, Engine::Tick takes 20ms.
However, the frame 2 takes 43ms(23+20), especially in Unreal Insights, it looks like very bad.

I wander that why not move the sleep call to after Engine::Tick? it only depons current frame’s tick time rather than previous frame’s.

Oh, I see what you mean. If the delay was part of the previous frame (but included at the end), it would all add up to be around 33.3 ms. But as it is now, it bounces up and down.

I don’t know why they did that. Could be that when a frame is done rendering, that’s the end of the frame and changing it to add delays at the end would have complicated things. They would have to move when a frame actually ends with logging and such. And maybe mess with when the frame swap happens which could cause you to miss vsync if not properly implemented. But that’s just a guess.

In your example, we have:

Delay part of beginning of frame (current implementation):
12.2ms delay, 23.8ms frame time, total 36ms
10.5ms delay, 14ms frame time, total 24.5ms

And it will continue to go up and down like that.

But if the delay were included at the END and part of the previous frame, you would get this:
21.1ms frame time, 12.2ms delay, total 33.3ms
23.8ms frame time, 10.5ms delay, total 34.3ms
14ms frame time, 19.6ms delay, total 33.6ms

I used actual numbers from your screenshot.

So yeah, I see where you’re coming from. I have no idea why they did it like the first example.

But note that it is 30 fps. The frame times are just not split up in an even manner.

Is there any way to fix this issue? I’m using Unreal Insights for performance optimization, but it becomes difficult due to the unstable frame rate.