Skip to content

fix: improve autohide animation responsiveness#521

Open
misterclayt0n wants to merge 2 commits into
pop-os:masterfrom
misterclayt0n:fix/autohide-animation-stutter
Open

fix: improve autohide animation responsiveness#521
misterclayt0n wants to merge 2 commits into
pop-os:masterfrom
misterclayt0n:fix/autohide-animation-stutter

Conversation

@misterclayt0n
Copy link
Copy Markdown

@misterclayt0n misterclayt0n commented Dec 15, 2025

Summary

This PR fixes stuttering in the panel autohide animation, especially noticeable at 60Hz refresh rates.

Problem

The autohide animation was dropping frames, causing visible stutter. Profiling revealed two issues:

  1. Event loop timing: When the panel was hidden, the main loop used a 300ms dispatch timeout. The prev_dur backoff variable could accumulate up to 100ms and carry into the animation, causing slow polling during transitions.

  2. Delayed surface commits: Margin changes during animation were batched with rendering and only committed when the next frame callback arrived, adding unnecessary latency.

Solution

Event loop timing (xdg_shell_wrapper/mod.rs)

  • Explicitly detect animation states (TransitionToHidden/TransitionToVisible)
  • During animation: always use 16ms dispatch, 1ms sleep, don't accumulate backoff
  • Reset timing state when animation starts or stops

Immediate commits during animation (panel_space.rs)

  • Add commit_immediately parameter to set_margin_with_offset()
  • Commit surface immediately after margin changes during animation
  • Eliminates waiting for next frame callback

Exclusive zone optimization (panel_space.rs)

  • Set exclusive zone once at animation start/end instead of every frame
  • Reduces compositor relayout work during animation

Profiling

The timing metrics were collected using Tracy (https://github.com/wolfpld/tracy) instrumentation temporarily added to cosmic-panel. The profiling code was used only for diagnosis and has not been included in this PR to keep the changes minimal and focused on the fix itself. However, if deemed appropriate, I have these tracy changes in my local machine, and I can upstream them as well in another PR.

Metrics

Metric Before After
Avg round-trip ~37ms ~23ms
P99 latency ~100ms ~51ms

Demo

2025-12-15.18-26-41.mp4

Animation feels overall snappier.

Testing

Tested on 60Hz display with autohide panel. Animation feels smooth with no latency.

Instead of rendering content with a client-side offset during autohide
animations, request the compositor to move the surface by adjusting
layer-shell margins. This delegates the animation movement to the
compositor which may be able to optimize surface repositioning.

Changes:
- Add set_margin_with_offset() for animation-aware margin setting
- Update TransitionToHidden/TransitionToVisible to set margins each frame
- Remove render offset (anim_gap_translation) from render.rs
- Remove anchor_gap from background and input region calculations in layout.rs
misterclayt0n added a commit to misterclayt0n/cosmic-epoch that referenced this pull request Dec 15, 2025
Points to misterclayt0n/cosmic-panel@fix/autohide-animation-stutter
which includes:
- Improved event loop timing during animations
- Immediate surface commits during margin animation
- Exclusive zone optimization

PR: pop-os/cosmic-panel#521
@Restioson
Copy link
Copy Markdown

Restioson commented Jan 27, 2026

I installed this fork locally and it seems to make it a bit smoother. Thanks!

@jacobgkau jacobgkau requested review from a team January 28, 2026 16:02
@Milli189
Copy link
Copy Markdown

would this fix this issue? pop-os/cosmic-epoch#2677

Copy link
Copy Markdown
Collaborator

@wash2 wash2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of rendering content with a client-side offset during autohide
animations, request the compositor to move the surface by adjusting
layer-shell margins. This delegates the animation movement to the
compositor which may be able to optimize surface repositioning.

We did use this method in the past, but I don't believe this kind of method will interact properly with overlap notify protocol

/// `anchor_offset` is negative to push the panel off-screen (hiding),
/// and zero when fully visible.
///
/// If `commit_immediately` is true, commits the surface right away without
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really necessary? I don't think we want to render without waiting for frame callbacks.

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.

4 participants