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

Update step jumps massively 1 frame after Fusion is loaded #357

Open
funwolf7 opened this issue Jun 30, 2024 · 1 comment
Open

Update step jumps massively 1 frame after Fusion is loaded #357

funwolf7 opened this issue Jun 30, 2024 · 1 comment
Labels
broken Something isn't right ready to work on Enhancements/changes ready to be made

Comments

@funwolf7
Copy link
Contributor

The update step is always 0 when Fusion is loaded, and then will become os.clock (in the case of RobloxExternal being used) upon next step, causing a massive jump. This in turn affects TweenScheduler/SpringScheduler in the main branch and ExternalTime in the push-pull-execution branch.

This causes any Tween or Spring made in the same frame that Fusion is loaded to jump to completion the next frame.

@funwolf7 funwolf7 added broken Something isn't right not ready - evaluating Currently gauging feedback labels Jun 30, 2024
@dphfox dphfox added ready to work on Enhancements/changes ready to be made and removed not ready - evaluating Currently gauging feedback labels Jun 30, 2024
@dphfox dphfox moved this to To Do in Fusion 0.3 Jun 30, 2024
@funwolf7
Copy link
Contributor Author

funwolf7 commented Jul 1, 2024

There is a TODO in External.luau that hints at the solution:

Fusion/src/External.luau

Lines 115 to 117 in 259e561

TODO: This epoch may change between providers. We could investigate ways
of allowing providers to co-operate to keep the epoch the same, so that
monotonicity can be better preserved.

A system to preserve the time would fix not only this issue but also the issue of swapping external providers. When I discovered this bug about a week ago (didn't think about making an issue for some reason), I thought about a system which would allow this without requiring the providers to do much.

Currently, "now" is passed from the external provider to Fusion whenever an update step happens. For this idea to work, Fusion would need to be able to ask the external provider for "now."

Essentially, the idea is that Fusion has its own "standard time" that is used internally by Fusion, and each provider only needs to give Fusion its "local time." To translate from local time to standard time we can use a local and standard reference timestamp that we know mean the same timestamp. Simply subtract the local reference timestamp from the current timestamp and add that to the reference timestamp.

currentStandardTime = currentLocalTime - localReferenceTimestamp + standardReferenceTimestamp

The easiest reference timestamps are when providers change. To get the standard reference, get the standard time using the old provider (if none exists, keep the previous standard reference). To get the local reference, ask the new provider for its current local time (if none exists, do nothing).

Both reference timestamps can start at 0. When the first provider is added, it will begin increasing monotonically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken Something isn't right ready to work on Enhancements/changes ready to be made
Projects
Status: To Do
Development

No branches or pull requests

2 participants