Updating instances in a function which is looped with a timer is killing fps

I have this function:

http://puu.sh/hwzPy/46d20affc9.png

It is called by a timer every 0.1 seconds:

http://puu.sh/hwzRJ/808bcedd23.png

The function is updating 500 instances. Unfortunately, this is decreasing the fps extremely. The stats look like this:

http://puu.sh/hwua3/45c2681455.png

But the stats are wrong, I get something like 2 fps. The stats don’t even make sense, since either GPU or Game has to be equal to the frame time. So, I get 2 fps.

If I disconnect the timer and instead run the function every tick:

http://puu.sh/hwA2H/0695ee1db0.png

Then the fps should be even worse, but no, they are not! With running the function every tick, which is more often than 10 times a second, I get this stats:

http://puu.sh/hwAdW/6b2279696e.png

And these stats are correct, it’s running smoothly with ~30 fps. So the GrowTree function is called 30 times a second instead of 10 times with the timer, but the fps are 100 times better.

Does not make sense. So there has to be a bug with the timer.

Here you have a repro project:

Just open the Trees blueprint and disconnect the timer and connect the function to the tick to see the difference.

There may be a few things gs going on.

I would put a print statement in the function as its called and one when it completes. what happens if the function is called again before it completes.

This is an area you may want to put into C++ but you will still potentially have undefined behavior if you are modifying the contents of a list simultaneously. Regardless of the fps inconsistenvies I’d expect other bugs as well if that loop is run again before it completes the first time. If it is in series and is waiting to complete there is your blocking behavior.

I am not modifying content simultaneously. You see, if I call the function every tick I get 30 fps. So if I want to do the same thing 10 times a second, I would not do anything simultaneously since 10 times a second fit’s perfectly in 30 available fps, so the timer would just do the same thing as the tick, but just every third frame. But it does not, and this is the bug.

Hi ,

I have been able to reproduce this on my end and have entered a bug report, UE-14819 to be assessed by the development staff.