Incorrect determination of an infinite loop

Hi.

UE 4.8 P4 incorrectly detects WhileLoop as infinite.

I have a BP script

http://s6.postimg.org/e0wjfa9v5/screenshot_116.png

As you see, there is one WhileLoop. It is loop while MousePressed = true and MousePressed is true only when Mouse Button is Pressed. When Mouse Button is Released, MousePressed = false. And I’ve added Delay to reduce CPU load of the cycle.

Why UE 4.8 P4 shows error

http://s6.postimg.org/4ue8s04mp/screenshot_118.png

I think, it’s bug.

Video with how to reproduce bug: [click][3]

I think, theoretically no one has written an algorithm which can detect an infinite loop, UE just checks if something loops 10,000 times and kills the program because it assumes it will keep going (and at that point you wouldn’t be able to stop it yourself without killing the process). Because of this, while loops often result in infinite loop crashes, in my experience I just avoid them where possible. I think in your case you might be able to still get away with this if you use a retriggerable delay (it’s just a different node that does the same thing) instead of a delay, this has sometimes helped me with recursive code, I don’t know why they are two different nodes but that could be part of your problem. I think the delay node only runs once, so you will have a .2 second delay, then 9,999 instant iterations and a crash. But let me know if that doesn’t work.

Thank you very much!!!

Can you post your answer?

Now it works good!

http://s6.postimg.org/mmzszvlv5/screenshot_120.png

Solved with retriggerable delay:

a delay will not stop or pause a while loop, a while loop continues until its condition is changed to false. it will not stop for anything, and will not allow the game to think about anything else until it is complete. if it doesn’t set its conditional to false at some point during the loop, it will crash your game with an infinite loop error.

putting a delay inside a while loop is an automatic infinite loop, because the delay requires time to pass, and the while loop doesn’t allow time to pass.

Why it will freeze game?

I did added Delay!

As I understand, Delay must delay the loop and it should not give loop to hung the game…