flandreas / antares

Digital circuit learning platform
49 stars 6 forks source link

Odd visual circuit state with slow simulation speeds #746

Closed flandreas closed 5 months ago

flandreas commented 5 months ago

When simulating a circuit at slow speed, the rendered circuit state (wire colours, LEDs, counter outputs etc) is odd.

The circuit works correctly, but the way it is displayed during simulation is not what the user expects at slow speed. The circuit seems to make large jumps, while the visual representation is updated only once in a while.

https://github.com/flandreas/antares/assets/24633141/36a00ec6-6061-48da-81d6-a58020b9320d

This is because the simulation is driven by a timer going to sleep in order to slow down simulation. However, the simulation calculates a lot of pending simulation requests when the timer is active. In the example above, the timer wakes up every 1 to 2 seconds and executes thousands of simulation requests. During that time, the UI is not updated, which leads to

This odd behaviour was probably introduced with #518 "Improve simulation speed slider behaviour", which attempted to harmonise the three speed ranges "Use", "Observer" and "Explore" by avoiding abrupt speed changes at their boundaries.

Improve the timing and repainting strategy such that the simulation appears smoother with slow simulations.