Skip to content

Introduce new Lua APIs to query animation status and progress#337

Open
jbms wants to merge 1 commit into
dawsers:masterfrom
jbms:lua-animation-stepping
Open

Introduce new Lua APIs to query animation status and progress#337
jbms wants to merge 1 commit into
dawsers:masterfrom
jbms:lua-animation-stepping

Conversation

@jbms

@jbms jbms commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This adds the following Lua APIs:

  • scroll.animation_get_duration(): Returns the duration of the current animation in milliseconds.
  • scroll.animation_get_elapsed_time(): Returns the elapsed time of the current animation in milliseconds, taking manual stepping into account.

These APIs allow tests to verify animation geometry and progress without relying on real-time delays.

This also updates the Python tests to run faster and more robustly.

Disable animations by default in the test compositor configuration to avoid unnecessary transaction delays. Tests that explicitly require animations (e.g. animation offset or workspace animation tests) use custom fixtures that enable and configure animations.

Refactor existing integration tests to eliminate time.sleep:

  • tests/test_geometry.py: Rewrite test_animating_geometry to use manual stepping and the new animation time APIs.
  • tests/test_normal_exit.py: Use subprocess.Popen.wait instead of a manual polling loop.
  • tests/test_workspace_split_uaf.py: Use the shared compositor (since animations are now disabled by default).
  • Other tests: Replace fixed sleeps with wait_for_idle or wait_for_client_map to wait for transactions to settle.

Add a new test tests/test_animation_offset.py to verify the new animation time APIs under both normal and manual stepping modes.

Implement a thorough reset mechanism for the session-scoped scroll_compositor fixture:

  • Wrap the session-scoped instance in a function-scoped fixture that calls ScrollInstance.reset() after each test.
  • reset() uses kill all to close all views, unplugs extra outputs, reloads the sway configuration to reset defaults (which also recreates the Lua state and discards registered callbacks), and recreates the default workspace 1 to reset its layout modifiers.

Optimize test suite execution speed:

  • Add pytest-xdist to the Nix development shell.
  • Configure pytest.ini to run tests in parallel with 4 workers by default (-n 4), which is stable under ASan and avoids OOM/thrashing.
  • Enable compiler optimizations (-Dbuildtype=debugoptimized for -O2) when building the compositor for tests under ASan.

@dawsers

dawsers commented Jun 25, 2026

Copy link
Copy Markdown
Owner

No, I don't want people to control the compositor from Lua. The idea of Lua is to write simple scripts, not provide a framework to run tests on the compositor.

Also, I don't want the test suite to become an ends in itself, and we are slowly getting there. More often than not, tests are good, but they quickly become obsolete when a bug is fixed, and regressions are not even easy to find using the old tests because they usually happen because of new code, so in the end you have a huge test suite where finding things is hard, and it only proves lots of old bugs were fixed.

I prefer to document the issues and explain why they happened than to have a myriad of tests that only prove a bug was fixed.

@jbms jbms force-pushed the lua-animation-stepping branch 3 times, most recently from 7378f00 to 435a2b4 Compare June 26, 2026 04:24
Introduce new Lua APIs to query animation status and progress.

Also includes testing infrastructure and tests:
- Added `tests/test_leak_two_clients.py` to check for runtime leaks with clients active.
- Added `tests/test_shutdown_events.py` and `tests/test_shutdown_lua_callbacks.py` to verify shutdown behavior and Lua callbacks.
- Added `test_normal_exit_with_bar` to `tests/test_normal_exit.py` to ensure `scrollbar` is covered by LSan checks during normal shutdown.
@jbms jbms force-pushed the lua-animation-stepping branch from 435a2b4 to af3dfa2 Compare June 26, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants