Skip to content
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

Jumping to high timewarp levels from off-rails will alter the active vessel's orbital elements #170

Closed
JonnyOThan opened this issue Dec 3, 2023 · 4 comments
Labels
kspBug Identified KSP issue

Comments

@JonnyOThan
Copy link
Contributor

https://www.reddit.com/r/KerbalSpaceProgram/comments/189fr5b/this_glitch_is_occurring_when_i_try_to_go_to_duna/

I've seen this happen so often that using 5x timewarp first is just muscle memory now. If we could fix this one it would be a huge benefit.

On the other hand, the workaround is not difficult. So either you learn the workaround or you learn to install KSPCF. I think the former is probably easier but it's the principle of the thing...

@gotmachine gotmachine added the kspBug Identified KSP issue label Dec 6, 2023
@gotmachine
Copy link
Contributor

gotmachine commented Dec 6, 2023

I guess this happened to me too, but not nearly often enough to identify why it was happening.
A reproducible setup or save would be helpful...

If I were to take a guess, I'd say this might have to do with the TimeWarp class wrongly assuming a 1:1 call ratio between the TimeWarp.autoWarpTo coroutine (which is yielding on FixedUpdate) and stuff happening in Update(). In the linked reddit video, the user in in "yellow" lag range, which means that he is likely having multiple FixedUpdate cycles back to back per Update cycle (which will get worse when the "max physics delta-time per frame" is set to higher values).

One way to verify such a theory in the presence of this bug would be to set Time.maximumDeltaTime = 0.02 and see if the bug still reproduce (unfortunately, it can be set lower than 0.03 in the KSP main menu settings, but doing so might still have an effect). If it doesn't, a quick and dirty workaround would be to force maximumDeltaTime for a few frames when the TimeWarp.autoWarpTo coroutine is spawned, but identifying the root cause would be nice, although in my experience fixing the root cause of such synchronization issues is difficult without triggering other side effects.

Edit : yep, can confirm this is the issue. I can reproduce it consistently by putting a 1500 part vessel in orbit while having the max dt per frame at 0.12, and engaging max timewarp speed.

@JonnyOThan
Copy link
Contributor Author

Awesome. I'm not too familiar with the Timewarp system but the problem is not limited to "autoWarpTo" - which I think you confirmed? You can also trigger it by clicking the max warp button in the UI.

@gotmachine
Copy link
Contributor

Yeah, I wrote that before testing, but this is reproducible no matter the method used to engage timewarp.

I need to do some proper debugging, but I suspect this won't be so easy to fix (just like with other similar KSP issues involving update/fixedupdate being wrongly assumed to be in prefect sync).

gotmachine added a commit that referenced this issue Dec 6, 2023
…12.5] Fix active vessel orbit moving randomly when engaging timewarp while under heavy CPU load.
@gotmachine
Copy link
Contributor

Fix included in 1.32.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kspBug Identified KSP issue
Development

No branches or pull requests

2 participants