Three-line function yielding wildly different results on M1 mac, compared to Windows

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By larbguy

This is the function in question:

func sleep(slowDownAmount, duration):
Engine.time_scale = slowDownAmount
yield(get_tree().create_timer(duration * slowDownAmount), "timeout")
Engine.time_scale = 1.0

It doesn’t seem to execute in the same way on an m1 mac in comparison to when i run the identical project on windows. i’ve had discrepancies in the past with the two comps im testing on but those were primarily jittering issues and i ended up figuring they out were tied to frame rate and refresh rate (_process / _physics_process). This function is being called on from a signal (on area entered)

The function works as intended on Windows, and it ‘works’ on the m1 mac, but the same values passed in yield very different results compared to windows (in terms of the sleep duration) and weirdly, anything below .4 seconds durations is completely unnoticeable on the m1 mac, as if the yield line isn’t executing or something. any advice is greatly appreciated

I manually created a timer and printed the timeleft in _physicsprocess to see if something would avail itself. The timer was set to 0.021 seconds.

on windows, it printed 0.021, then jumped to 0.013361, then 0.012669, and so on, descending to zero pretty evenly from there and each print showed a decrement of around 1 thousandth.

on the m1 mac, it printed 0.021, then jumped all the way to 0.0043, and decremented every 1 thousandth of a second from then on. I tried this multiple times to see if there were any discrepancies in the logging from physics process, but it printed the same jumps for both every time.

so i don’t know a fix, but at the very least, theres some more info. pretty reliably, and not just tied to timers created as 1-shots as part of a yield, on the m1 mac it seems to always just skip a chunk of time after the start, but it still recognizes that initial time.

There’s probably a way better way of describing all this but it’s pretty above my ability level lol. hope this adds more useful info, thanks again for any help

larbguy | 2021-10-05 07:06