Infinite loop detected in a timeline

in UE 5.3.2 (on either windows 10 or 11) i wrote a ‘marble run’ VR application. That is, the user creates a track and a marble rolls down the track. If I create a PCVR app, I need considerable GPU power for UE physics to work correctly. If I use the metaXR plugin (instead of openXR) so I can place it on a Meta VR device (either quest 2 or 3), the hardware does not do UE physics well (i.e. the marble can fall through the track often).

Fine, instead of using UE physics, I create a spline component for each track segment and use a timeline to move the marble along the spline. The timeline length is 1 second and so I vary the Play Rate according to speed/spline distance during timeline update. Also during the timeline Update, I implement physics (use mechanical energy conservation to find the new marble speed). If the new speed isn’t allowed, then I back up the marble to its last valid position, reverse its direction and tell the timeline to Reverse. It is also possible that the marble will fall off the track. I can also detect that in which case I tell the timeline to Stop and let UE physics take over. When the marble is on a spline and running in the timeline, collisions and physics are off. Only when it leaves a track are collisions and physics turned back on (and there the marble watches if it Hits a new track and if so, starts the new timeline).

The problem is even if the marble doesn’t fall off or reverses direction, I randomly get ‘infinite loop detected’ in the Editor when the marble is being animated by the timeline. If I package the PCVR app, I can get a hard crash. The call stack isn’t very helpful, just points to the timeline’s update function.

The thing is, there is no loop in the timeline update function. I do do quite a bit of calculation during the Update in the timeline (i.e. figuring out if it reversed, fell off and some drag so that mechanic energy isn’t conserved so that the marble will stop rolling if it’s trapped in a section of the track, update Play Rate, update location of marble, update rotation of marble, etc.). Is this the problem? Too much stuff during an Update function which throws this ‘infinite loop detected’? Or do I actually have some loop hidden in there somewhere? I’ve run in the debugger and it doesn’t appear I have an infinite loop being triggered.

all of this work is done in the marble’s blueprint.

Suggestions, hints and ideas most welcomed.

If your timeline time is very short like in a tick you are doing lot of things, it can trigger this yes.
Try to increase your time to see if it really that timeline that causing that issue.
Otherwise it might be a function calling other function adding up the loop instruction.

You might want to check on Session Frontend for profiling(if you have unreal 5.2)

1 Like

Thanks Arodi007.

Timeline is setup for 1 second, but I play w/ the Play Rate (= speed/spline length) so the wall time is different. I’ll play with that. The only function I call in the Update is to a meta sound to change a parameter (i.e. change the frequency and loudness of the marble rolling which depends on the speed of the marble). I also call a macro that calculates the final speed, reversing boolean and falling off boolean. Everything else is directly off the Update pin of the timeline.

thanks for the confirmation that this ‘infinite loop detected’ may have nothing to do with an infinite loop.

1 Like

Due to an implemented error in the logic, it turns out the Timeline was occasionally being called many times. So the error was, in fact an infinite loop. I misinterpreted what a Deactivate node actually does. Changing the implementation avoids the infinite loop detection (i.e. toggle Physics simulation (on/off) and collisions (Enabled/None) depending if we are going to do UE physics or animate with a Timeline).

So even if you’re sure there is no way an infinite loop can be generated, look closely at how you start the Timeline and make sure it’s not called again when it is already running. My error was assuming it was logically impossible, but a Print String showed that wasn’t always the case.

I marked Arodi007 as correct, since it did mention the ultimate error.

Just a small note, an infinite loop from a conventional programming is somewhat different from unreal perspective.

Let say you do a For Each 10, usually it should be 10 loop but it more than that in terms of instructions execution, if you double click the for each node, you will see there more node inisde it, than why it more than 10.

As you have notice there also Phyiscs tick, Widget tick, Timeline, Function calling other Function etc…, doing all these at the same time trigger the limiter:, it also why sometime infinite loop trigger and sometime not.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.