dclause / dclause/hermes-five

Improve Animation Engine Performance & Frame Accuracy

Open
#47 0 comments 0 reactions 0 assignees View on GitHub
code quality feature request performance Plan
Dominant language
Rust
Stars
38
Forks
1
PR merge metrics
No merged PRs in 30d

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**

1. 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.

2. 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.

3. 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.

4. 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 ?

4. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.