mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
509305ee61
Three findings from a pass over performance and React practice. Two options were synced from their params in effects, which is the pattern the React docs warn against. It is not only style here: an effect runs after the commit, so the view painted a frame in the previous orientation before correcting itself, and on a prompter that reads as a flash. Both the flip pair and the live speed are now adjusted during render, which React discards before it reaches the screen. The flip state also collapses from two booleans and two effects into one object. The keyboard handler assigned its arguments to a ref during render so the listener could stay installed once. That is a side effect in a place React may run twice or throw away, so it moved to an effect. The animation frame loop wrote scrollTop on every frame even when nothing had moved, so a paused prompter kept poking the DOM sixty times a second. It now writes only when the position changed. Measured rather than assumed, against a 200 event script, 214 blocks and a 198000 pixel document: 16.7ms median frames with no long tasks, both paused and running. A speed change costs a single frame at 29ms for the re-render. The worry about long rundowns needing virtualisation does not hold at this size. Confirmed the view still compiles under the React compiler after the render phase updates, at 51 memo caches. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cb8RVPNQ2ETPJxdy4b8CHf