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

Timer: fix duplicate ticks when stopping and starting fast #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ailac22
Copy link

@ailac22 ailac22 commented Aug 15, 2022

When stopping and starting a timer fast (under 1s), tick chains duplicate because the previous emitted tick hasn't been dequeued yet in the timer's update function. When this happens the timer advances faster than clock speed.

I've sketched this solution in case it's an adequate solution (I've not thoroughly tested it though). Ticks include a cycleId number that changes each time a model is started. If the timer is stopped/started too fast, it will be detected in the Update function than one of the ticks was sent before stopping the timer.

When stopping and starting a timer too fast, old ticks emitted before
stopping are not dequeued correctly fast enough, and instead double or more "tick
chains" are emitted. An int indicating to which cycle a tick belongs can
solve this
@muesli muesli added the bug Something isn't working label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants