jbuchermn/newm

Newm becomes unresponsive after "Skipping moot animation"

wildlightecho opened this issue · 3 comments

Whenever this conditional triggers, it blocks all further animations. It seems as though the previous animation never finishes and subsequent ones are only added to the queue and never execute.

Debug log for a normal animation:

[DEBUG] layout.py:885 2022-07-26 12:21:48: Gesture Gesture(swipe-4)...
[DEBUG] layout.py:927 2022-07-26 12:21:48: ...SwipeToZoom
[DEBUG] layout.py:266 2022-07-26 12:21:48: Queuing overlay
[DEBUG] layout.py:288 2022-07-26 12:21:48: Thread: Starting overlay...
[DEBUG] layout.py:978 2022-07-26 12:21:48: Going to enter <newm.overlay.swipe_to_zoom_overlay.SwipeToZoomOverlay object at 0x7fe3c05ed3c0>...
[DEBUG] layout.py:997 2022-07-26 12:21:49: Going to exit overlay...
[DEBUG] layout.py:1002 2022-07-26 12:21:49: ...destroy
[DEBUG] overlay.py:44 2022-07-26 12:21:49: Overlay: Exit animation
[DEBUG] layout.py:270 2022-07-26 12:21:49: Overlay-safe animation not queued
00:00:08.570 [DEBUG] [../src/wm/wm_output.c:153] Output 1 dropped frame (29.00ms)
[DEBUG] layout.py:296 2022-07-26 12:21:49: Thread: Starting animation...
[DEBUG] overlay.py:50 2022-07-26 12:21:49: Overlay: Exit animation completed
[DEBUG] layout.py:1006 2022-07-26 12:21:49: Overlay destroyed
[DEBUG] layout.py:278 2022-07-26 12:21:49: Thread: Finishing overlay...
[DEBUG] layout.py:1010 2022-07-26 12:21:49: Resetting gesture
[DEBUG] layout.py:303 2022-07-26 12:21:49: Thread: Finishing animation...

Debug log for the final animation before freezing:

[DEBUG] layout.py:885 2022-07-26 12:21:49: Gesture Gesture(swipe-3)...
[DEBUG] layout.py:914 2022-07-26 12:21:49: ...Swipe
[DEBUG] layout.py:266 2022-07-26 12:21:49: Queuing overlay
[DEBUG] layout.py:288 2022-07-26 12:21:49: Thread: Starting overlay...
[DEBUG] layout.py:978 2022-07-26 12:21:49: Going to enter <newm.overlay.swipe_overlay.SwipeOverlay object at 0x7fe3c05edb10>...
[DEBUG] layout.py:997 2022-07-26 12:21:50: Going to exit overlay...
[DEBUG] layout.py:1002 2022-07-26 12:21:50: ...destroy
[DEBUG] overlay.py:44 2022-07-26 12:21:50: Overlay: Exit animation
[DEBUG] layout.py:270 2022-07-26 12:21:50: Overlay-safe animation not queued
00:00:09.884 [DEBUG] [../src/wm/wm_output.c:153] Output 1 dropped frame (26.00ms)
[DEBUG] layout.py:296 2022-07-26 12:21:50: Thread: Starting animation...
[DEBUG] layout.py:223 2022-07-26 12:21:50: Skipping moot animation
[DEBUG] layout.py:303 2022-07-26 12:21:50: Thread: Finishing animation...

The issue seems to be fixed by making the _animate_to call execute regardless of whether the final state is the same as the current state or not, by removing the if-statement and making the else clause (line 226) execute every time:

newm/newm/layout.py

Lines 218 to 226 in bcea895

if self._final_state is not None:
# Enforce constraints on final state
self._final_state.constrain_and_validate()
if self._final_state == self.layout.state:
logger.debug("Skipping moot animation")
self._final_state = None
else:
self.layout._animate_to(self._final_state, self.duration)

This is likely a band-aid fix, as I could not locate the exact source of the issue. Something about not executing the animation is causing on_overlay_destroyed to not trigger correctly, as Overlay: Exit animation completed and Resetting gesture never appear after the freeze:

newm/newm/layout.py

Lines 1004 to 1010 in bcea895

def on_overlay_destroyed(self) -> None:
logger.debug("Overlay destroyed")
self.thread.on_overlay_destroyed()
self.overlay = None
logger.debug("Resetting gesture")
self.reset_gesture()

Thanks a lot for the detailed report. I think, implementing the "moot" animation was a bit of a quick fix, which I didn't test properly...

Unfortunately, I'm not at home and can't test, but I suspect the issue is that, in case of a such a skipped animation, the then function is not called (in check_finished, lines 199-200). Can you try adding this call before line 190 e.g.?

Awesome, thank you, that seems to have solved the issue (and more cleanly then my "fix" lol). I'll make a pull request with these lines added there.

Just merged :)