From ca6108baf4c90bdac8ebaea2d88329e77777377e Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Mon, 13 Sep 2021 17:03:01 +0300 Subject: osc.lua: avoid infinite ticks loop on idle Before this commit, animation-end was handled at render(), however, it's not called on idle, which resulted in state.anitype ~= nil, with nothing to reset it during idle, which caused in an infinite tick() loop (starts on first mouse move). Now tick resets the animation on idle, and also, as a safety measure, if we're past 1s after the animation deadline. The safety measure is because the osc states are complex, and it's easier to detect a "we really shouldn't be animating now" at tick() itself rather than detecting the exact states where animation should be reset. Generally, the safety mmeasure is not needed. --- player/lua/osc.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 4d37d766d3..19f4e9b8c4 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -2609,7 +2609,17 @@ function tick() state.tick_last_time = mp.get_time() if state.anitype ~= nil then - request_tick() + -- state.anistart can be nil - animation should now start, or it can + -- be a timestamp when it started. state.idle has no animation. + if not state.idle and + (not state.anistart or + mp.get_time() < 1 + state.anistart + user_opts.fadeduration/1000) + then + -- animating or starting, or still within 1s past the deadline + request_tick() + else + kill_animation() + end end end -- cgit v1.2.3