-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Motivation
Current animation engine is functional but lacks precision and scalability when attempting to control devices (like LEDs or servos) at higher frame rates (~20 FPS). Several areas have been identified that can be optimized to improve determinism, timing accuracy, and overall performance in a multi-track context with limited I/O bandwidth (e.g., serial comms).
Identified Optimization Areas
-
Keyframe Search Complexity
Currently O(N) per frame to find applicable keyframes across tracks. This is Acceptable for now due to low N, but may become a bottleneck.
=> Potential improvement: binary search on sorted keyframes, or prebuild flat timeline index. -
Box / Clone Overhead
Heavy use of Box and .clone() on State objects.
=> Suggestion: Use &dyn OutputDevice when mutation not needed.
=> Consider moving to Rc or using Cow for cloned data. -
Time Drift / Inaccuracy at High FPS
Observed 100ms keyframes blink between 110–130ms in real-world. The cuase seems to be the order of operations: time to compute + send + wait until next frame adds non-negligible delay.
=> Precompute frame output state, then delay until precise tick.
=> Use tokio::time::interval() to drive frame rate reliably. -
Generic Timing Model
=> Using a tokio interval() system, can be / should we do "step by step" animation ?
=> How about having a speed factor (speed: f32), Should it be modifiable on the fly ? -
Track Conflict Detection
Should add_track() enforces no overlap of keyframes ? How to prevent forcing .unwrap() in most usages.
=> consider builder pattern or API that accumulates diagnostics.