-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
OpenGL GPU-accelerated terminal screen stutters with Vim, doesn't happen with neovim #8002
Comments
This is not reproducible. No idea what you are doing in those videos, I don't see a :redraw! command being typed. Please provide a reproducible example without using a plugin. E.g. editing the Vim source code. |
@brammool Here we go... Below is a complete example with no plugins & me typing vim_stutter_minimal.mp4Steps are same as in video:
Please let me know if you are able to reproduce with these steps.
|
What I see here is perfectly normal: screen is cleared and then the text is drawn. |
@brammool: @bfredl from neovim team has some preliminary insight in his comment: neovim/neovim#14225 (comment). @bfredl: Any chance to see what's going on in Vim? Thanks! |
@brammool: @bfredl from neovim team has some preliminary insight in his comment: neovim/neovim#14225 (comment).
@bfredl: Any chance to see what's going on in Vim? Thanks!
I believe what is said here that Neovim doesn't clear the screen, but
draws over the text. In many cases that is slower, but the advantage is
that the user sees less flicker. A risk is that when some text was
drawn outside of Vim's control it might not be replaced.
The Vim :redraw command only has two modes: without !: redraw what is
outdated, with !: clear and redraw. There is no way to redraw with
NOT_VALID, which would redraw everything but not clear. Perhaps
":redraw all" could be added.
…--
hundred-and-one symptoms of being an internet addict:
74. Your most erotic dreams are about cybersex
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Good day @brammool Any updates on fixing this issue? Sorry to be annoying (I understand that your focus is now on vim9 and have read that You don't want to do this work by yourself, but seems like noone else have knowledge or willing to fix this either) and understandable that you personally do not have such issues. |
The priority on this issue is very low, since I don't see why a user would type ":redraw!", other then when the screen is messed up and then the behavior is totally justified. If screen redrawing is so fast, then why would there be any flicker? Is there any normal use that is affected? |
I guess OP missguide You or something. You don't need to invoke |
I don't know whether it will help, but clearing
|
Perhaps it's also worth setting |
When you say "it flickers" when you use CTRL-F, then it's normal that the screen is redrawn, since the text is updated. I'm not sure a recording is much help showing what you see. You can use the "script" command to record the output, comparing Vim and Neovim to see what is sent and finding the relevant parts. Perhaps a "clear screen" code t_cl appears? |
@lacygoill already had lazyredraw and Tested with |
To record the output:
To replay the recording:
On Ubuntu, the
The control sequences are documented here. The xterm package might provide a local documentation:
|
@lacygoill not sure really what is going on |
I guess that some escapes are missing from the log; they should be represented with their caret notation ( For example, this sequence:
Might actually be:
If so, it's probably how the terminal answers to a request about the cursor position. Here, it means that the cursor is on row 2, column 2. Anyway, about this question which was asked previously:
What's the value of the
For me, it's:
Can you find this sequence somewhere in the log? |
I posted the logs |
And yes I can find them in vim and neovim too. This logs were from just enering and leaving vim and neovim. Should I scroll for some time for relevent results? |
Yes, I think you should. I can't help much more, but here are 2 other suggestions. You can attach the logfiles to a github issue by dragging and dropping the files. This could help preserving special characters, such as raw escapes (and avoid the weird replacement characters Also, you might separate the escape sequences, one per line, with this substitution command:
Just to make the logs a little easier to read. |
vim.log neovim.log And this is how opening popup terminal window with vim neovim neovim.mp4Don't say to me you that you don't see the difference @brammool :) |
@lacygoill @chrisbra Thank You both. At least for learning some new stuff and to understand what is going on. |
I looked at only part of the output, but it appears that Vim's strategy is to minimize the text sent to the terminal, while Neovim avoids using the 'screen clear' sequence and instead sends a "clear to end of line' after every line. As an experiment, you could make a vertical split, which should Vim change strategy to avoid a clear screen. |
Make a vertical split and do the same thing i did before? |
I think so, yes. Start Vim with a vertical split (e.g. Don't forget to attach new logs to check how the vertical split influences the issue. |
I have the same problem. This happen almost daily when I use Fzf. |
script logs for one vertical split of python file with
|
It appears neovim uses "writedelay" differently, causing most of the difference in speed. I notice a few things. Vim clears part of the screen by outputting spaces, then draws text in that space, that looks wrong. The original question was whether a vertical split would avoid the screen-clear. It looks like it does. So did this solve the flickering? |
Oh sorry, then my screencasts a almost useless :(
Not really, not sure screencasts without writedelay with fps limits could show the difference but let me do some and see myself if it does, so i will then let you know. Can you also explain a little what is going on with the cursor on my first screencast of popup terminal? Why it jumping around so much? |
…d CTRL-B Problem: Redrawing a vertically split window is slow when using CTRL-F and CTRL-B. Solution: When deciding on USE_REDRAW bail out if scrolling more than three lines. (issue #8002)
@brammool with
|
Another question. Do you need logs for opening external tool in terminal popup window that causes inadequate cursor jumps or you are not intrested to fix this issue, just once again using such tool in neovim doesn't cause such abnormal cursor jumps? |
> It appears neovim uses "writedelay" differently, causing most of the difference in speed.
Oh sorry, then my screencasts a almost useless :(
They are useful to see how the redrawing works. You can't use it to
judge performance.
> So did this solve the flickering?
Not really, not sure screencasts without writedelay with fps limits
could show the difference but let me do some and see myself if it
does, so i will then let you know.
The statusline should not be cleared and redrawn now. I'm not sure how
serious this flickering is, I haven't really noticed it. Avoiding the
screen clear may cause other redrawing to become slow. I know most
terminal emulators can clear very fast, while drawing characters takes
much more time.
Can you also explain a little what is going on with the cursor on my
first screencast of popup terminal? Why it jumping around so much?
Probably the cursor is not disabled while redrawing. For a terminal Vim
cannot know how the job in the terminal uses the cursor. The cursor is
switched off when drawing, it's back on when it wasn't disabled in the
terminal.
…--
ROBIN: (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN: Oh ... wacho!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Didn't test this patch by myself yet, but i appreciate any work that you have done to at least reduce such flickering on some cases.
|
@hungpham3112 should be fixed with the last fzf commit junegunn/fzf@b3ab631 |
Is this working well enough now that this issue can be closed? |
Hello, Bram. Not sure if the problem was addressed. Redraw is behaving as documented, so Vim is doing it job right. So I guess this issue is intended behavior of the redraw. But the problem is that a lot of plugins overuse |
A way to clear the command line is Otherwise there is no specific issue remaining, let's close this. |
Another question. Do you need logs for opening external tool in
terminal popup window that causes inadequate cursor jumps or you are
not intrested to fix this issue, just once again using such tool in
neovim doesn't cause such abnormal cursor jumps?
There is support for showing and hiding the cursor in a terminal window,
is that external tool using it?
…--
Sorry, no fortune today.
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Yes. Currently it is after I have proposed to do so junegunn/fzf#2781 |
Describe the bug
Vim screen stutters a lot with modern OpenGL-based terminals that offload screen rendering to GPU. AFAIK the philosophy of these terminals is different, they don't redraw part of the screen, and rather update entire screen as its fast & cheap. The same stutter behavior is not seen in old terminals that use CPU to do the rendering, and draw only part of the screen that needs update. But users are & will keep moving to new OpenGL-based terminals in future as they are super fast & low power (even compared to GVim GUI on macOS).
To Reproduce
vim --clean
:e ~/.vimrc
:redraw!
multiple times.Expected behavior
There should never be screen stutters on openGL terminals when executing commands (like
:redraw!
). In this example it seems like:redraw!
is the culprit, thoughredraw
also does it when called from inside functions (like in plugin Startify [minimal example at bottom]). Note: NeoVim doesn't have such stutters, so it already is doing something different for redraws compared to Vim.MP4 Videos (new GitHub feature works only on laptop/desktop for me)
startify_stutter.mp4
startify_nostutter.mp4
The minimal .vimrc in case you want to try it with
:Startify
command in above videos:The above setup should also make stutters clearly visible in iTerm2.
Environment (please complete the following information):
Additional context
Options like
lazyredraw
, andttyfast
have no effect on this.The text was updated successfully, but these errors were encountered: