godot: OS.get_system_time_msecs output is wrong

Godot version:

3.2.3

OS/device including version:

OS: Arch Linux

Issue description:

When running OS.get_system_time_msecs() in _physics_process(), it seems to be counting incorrectly. The last three numbers will stay the same for multiple lines before flipping even though they’re supposed to be milliseconds. It’s hard to describe, so here’s a video of it happening:

https://user-images.githubusercontent.com/20866468/102701162-f440ef80-4208-11eb-9b7e-c9ca06ec1b32.mp4

Also, I’m not positive, but I think this might be causing some serious network sync latency issues, because my solution uses this function to sync the world state.

Steps to reproduce: Put print(OS.get_system_time_msecs()) in _physics_process()

Minimal reproduction project:

SystemTimeTest.zip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

One thing you can try is disabling vsync and see if that’s an issue with your setup (OS.vsync_enabled = false)

After disabling v-sync, my FPS starts out at one and climbs to 5 digits.

but you should also make sure that your drivers are working correctly and can run GL applications well

I can run GL applications well. I can even run Godot applications very well.

Also, in that game, unfocusing the game window made it drop down to 1, but refocusing it made it climb back up to 60. I’m starting to think that it has something to do with unfocusing the window. That’s what my new issue will be about.

Edit: #44741 is the new issue

So it just occurred to me that roughly the same output is printed exactly 8 times per iteration, which reminded me of this particular piece of code:

https://github.com/godotengine/godot/blob/31d0f8ad8d5cf50a310ee7e8ada4dcdb4510690b/main/main.cpp#L2064-L2068

I then managed to reproduce a similar output by executing the following snippet with godot --frame-delay 1000 -s main.gd

# main.gd
extends MainLoop


func _iteration(delta: float) -> bool:
	print(OS.get_system_time_msecs())
	return false

Output:

1608847883988
1608847883988
1608847883988
1608847883988
1608847883988
1608847883988
1608847883988
1608847883988
1608847884988
1608847884988
1608847884988
1608847884988
1608847884988
1608847884988
1608847884988
1608847884988
1608847885988
1608847885988
1608847885988
1608847885988
1608847885988
1608847885988
1608847885988
1608847885988

So the question now is: what is limiting the FPS?