-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a setting to force _physics_process()
to run in real-time (or flag up when it isn't)
#3612
Comments
I don't see why this slowdown would occur, especially in I'm pretty sure Windows does not have built-in power saving mechanics that automatically apply to unfocused windows or windows covered by another window. That said, for implementing server-authoritative physics with client-side prediction, you're probably looking for #2821 which is a more reliable solution. Fighting the operating system over priority or power saving issues rarely ends well… 🙂 |
_physics_process()
to run in real-time (or flag up when it isn't)
_physics_process()
to run in real-time (or flag up when it isn't)_physics_process()
to run in real-time (or flag up when it isn't)
I tried to replicate it on Windows. There was no change when the window went in and out of view (behind another window). However, there is an even worse problem when the window gets minimized... It looks like the
It's as though the code tries to compensate for the slippage during the minimization process, but gets it wrong. The problem is intermittent. Sometimes it goes the other way and it loses 0.05seconds instead of gaining time. It's easy to show this graphically with the following code: extends Node2D
var cumulativetime = 0.0
var Di = 0
var mfac = 50
var mfacy = 400
var X = [ ]
func _physics_process(delta):
cumulativetime += delta
var t = OS.get_ticks_msec()*0.001
X.append(Vector2(t*mfac, (cumulativetime-t)*mfacy+400))
Di += 1
if (Di % 60) == 0:
print(Di/60, " ", OS.get_time(), " ", cumulativetime - t)
if Di == 60*10:
$Line2D.points = PoolVector2Array(X) |
Please report this on the main Godot repository, and make sure to test this on both 3.3.4 and 3.4 (godotengine/godot#35617 may have introduced a regression here). |
I'm not sure if this is relevant, but could this Engine setting be the issue? |
Minimal example for reference |
Hey, Is this intended? |
Describe the project you are working on
A 2D ping pong networking demo https://github.com/goatchurchprime/godot_multiplayer_networking_workbench
Describe the problem or limitation you are having in your project
A networked ping-pong ball game I am writing depends on the cumulative time from the
_physics_process(delta)
and the value ofOS.get_ticks_msec()
to agree.This very simple piece of code shows how the cumulative time is consistent, until another window is put in front of the godot window for a few seconds.
Output:
The problem is I can't find a setting to stop this slow-down from happening, or a signal to detect when it happens so that I can tell my algorithms to stop working and reset during the time when the relationship is not valid.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The feature would make it easier to write+debug software that depends on the
_physics_process()
running predictably, or be flagged during periods when the timing is not going to agree.Usually this applies whenever there is any networking. A single player app slowing down or speeding up doesn't matter. But when there are two players they are usually each going to assume that the other is running at roughly the same rate. A signal from one that it has gone into hidden mode/suspended animation could be transmitted to the other players to explain why the data streaming from it is no longer agreeing.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
A function such as:
OS.set_priority(1)
Or a signal in
OS
that lets the software know that the state has changed between when_phsycis_process()
is running properly, and when it is go-slow mode because of something it can't control with the Windows GUI manager.The problem doesn't happen with the headless version, where there is no window to hide or be seen, so it's always running properly.
If this enhancement will not be used often, can it be worked around with a few lines of script?
It's possible to monitor the cumulative time and trigger my own signal when there is a slippage using the function above.
However, it's harder to detect when the slippage has ended and normal service has resumed. Possibly I have to watch for 5 seconds that the numbers aren't drifting before flagging that everything is back to normal.
Is there a reason why this should be core and not an add-on in the asset library?
This is a core function of the physics engine and timing.
The text was updated successfully, but these errors were encountered: