Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: mitigate the cursor flickering issue #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wnineg
Copy link

@wnineg wnineg commented Oct 4, 2024

Instead of letting the :hl to redraw all things globally, use the nvim__redraw api to limit the redraw on the notification windows only. The api also handles the case of redrawing during blocking events by flushing the screen changes.


Mitigate the issues #56, #63 and #273.

After some investigation, it came down to two culprits:

  1. The constant :hl commands (for fade in/out blending) that caused frequent global redraws.
  2. Good amount of notification window resizing/repositioning.

This PR tickles the first one but couldn't fully eliminate the issue. In situations when the redraws are intense, e.g. many/fat notifications fade in/out around the same time, the problem can still occur. However, even in those situations, the flickering issue would disappear as soon as all the fade in/out are done.

Side note: The flickering issue, at least for me, happened on Windows Terminal and WezTerm in Window. The nvim was run inside WSL. The flickering won't happen if I run WezTerm from WSL of VM. My theory is it is some throughput problem of the underneath ConPTY.


Comparisons:

Original Mitigated
nvim-notify-smallmsg-orig.mp4
nvim-notify-smallmsg-mitigated.mp4
nvim-notify-bigmsg-orig.mp4
nvim-notify-bigmsg-mitigated.mp4

Additional Change

This commit also removes the work done by 4144654. I checked the original discussion the commit referred to but failed to see how the change could help. So if I understand it correctly the commit was trying to solve the issue of the notification window (animation) getting blocked during blocking events. The redraw command you added in the commit, however, is usually executed through the main loop path so it could only be executed once per new notification and wouldn't help the animation to advance further. Instead, since the recurring WindowAnimator:_apply_win_state is already running outside of the main loop (because NotificationService:_run uses the deferring function), we could make use of it to just request a redraw with immediately flushing there to solve the blocking problem (tested with the getchar call followed immediately after a notification call).

This specific change does not contribute to the performance but I feel like somewhat related. If I misunderstood anything or you don't like this to be part of the commit, let me know :).

Instead of letting the `:hl` to redraw all things globally, use the
`nvim__redraw` api to limit the redraw on the notification windows only.
The api also handles the case of redrawing during blocking events by
flushing the screen changes.
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.

1 participant