Skip to content

:version takes about a second to display MacVim version info #815

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

Closed
mario-grgic opened this issue Dec 10, 2018 · 5 comments · Fixed by #840
Closed

:version takes about a second to display MacVim version info #815

mario-grgic opened this issue Dec 10, 2018 · 5 comments · Fixed by #840
Labels
10.14 Mojave Renderer Text rendering issues, including CoreText renderer
Milestone

Comments

@mario-grgic
Copy link

I'm on MacOS 10.14.2 and Xcode 10.1 and have configured MacVim as follows:

./configure --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-python3interp --enable-perlinterp --enable-cscope --with-compiledby="Mario Grgic" --enable-terminal

When you issue :version command in the GUI , there is now a noticeable delay before the command displays the version information. Command line version prints the version info instantly.

This is a regression from versions built with macOS 10.13 SDK.

@ychin
Copy link
Member

ychin commented Dec 11, 2018

It's related to the new Mojave renderer. Will need to take a look. Probably some de-generate case with tons of text draw calls all done at once.

@chdiza
Copy link
Contributor

chdiza commented Dec 11, 2018

I notice a delay too, but it's definitely not one second. It's much shorter (like less than .25 seconds). I had to run it a few times in comparison to the console version to even be sure that a delay existed. Either way, it should be fixed.

FWIW, I don't have any of the scripting languages compiled in.

@ychin ychin added the Renderer Text rendering issues, including CoreText renderer label Dec 12, 2018
@ychin ychin added this to the snapshot-154 milestone Dec 12, 2018
@amadeus
Copy link

amadeus commented Dec 20, 2018

It's also really bad if you run any sort of :! command that has a lot of output - for example a :!git pull that then spawns a ton of lines of text. I've had the entire app become completely unresponsive for about 10 seconds due to this.

The new renderer needs some pretty significant performance improvements I think.

Random thought - would there be any way we could copy the implementation from like iTerm2 or something? I imagine it's open source, it's pretty damn fast, could be really nice, but I imagine not a simple drop in replacement either.

@ychin
Copy link
Member

ychin commented Dec 21, 2018

As tagged in this issue, there should be some basic improvements to :version/:! by next snapshot (154), just to alleviate the situation, and I'm hoping to be able to revamp the renderer by snapshot-155.

When the new renderer was implemented it was mostly to make Mojave work again to unblock people so I didn't really have time to go and improve it, so now that it's somewhat usable that will be next.

I have looked at iTerm2 before and it's not a drop-in replacement and their Metal renderer doesn't support certain features like ligatures or transparency. My gut feeling from browsing through it is it would take more time to use it as well as re-adding features we have always supported than writing a new Metal renderer from scratch. The question is whether we want to completely accelerate the text drawing using a glyph cache (which would be faster but harder to support things like ligatures) or simply use the GPU to accelerate scrolling and compositing.

ychin added a commit to ychin/macvim that referenced this issue Feb 3, 2019
This fixes 10.14 Mojave's CoreText renderer taking a long time to render
:version / :ls / :! / :echo or similar commands.

This issue happened because the way Vim echos the output of those
commands is by issuing a draw calls in the pattern of "delete 1 line,
draw some text, delete another line...". Each line delete causes the
renderer to do a scroll. The pre-Mojave renderer relies on calling
scrollRect: but this doesn't work in Mojave anyway since that function
is deprecated and doesn't work in layer-backed views (which are now
mandatory). The new renderer's scrollRect: is a lot of slow since it's
doing image blits on CPU.

The fix is to implement a draw command optimizer that pre-processes the
draw calls first. It works by batching together all the "delete 1 line"
calls and combine into a single "delete N lines" call and put that in
the beginning, and fixing up all the other draw string command so they
draw to the right line instead of needing to be scrolled up. This makes
:version or the other calls feel instaneous now.

This fix is ultimately a hack and an intermediary solution before the
renderer can be replaced (since the slow CPU scrolling causes normal
usage to feel sluggish as well) by a GPU-based renderer and/or a
glyph-based one that caches the state of the texts so repeated scrolling
can be done by shuffling the glpyh data around instead of an actualy image
blit.

Fix macvim-dev#815
ychin added a commit to ychin/macvim that referenced this issue Feb 3, 2019
This fixes 10.14 Mojave's CoreText renderer taking a long time to render
:version / :ls / :! / :echo or similar commands.

This issue happened because the way Vim echos the output of those
commands is by issuing a draw calls in the pattern of "delete 1 line,
draw some text, delete another line...". Each line delete causes the
renderer to do a scroll. The pre-Mojave renderer relies on calling
scrollRect: but this doesn't work in Mojave anymore since that function
is deprecated and doesn't work in layer-backed views (which are now
mandatory). The new renderer's scroll implementation is a lot of slow
since it's doing image blits on CPU.

The fix is to implement a draw command optimizer that pre-processes the
draw calls first. It works by batching together all the "delete 1 line"
calls and combine into a single "delete N lines" call and put that in
the beginning, and fixing up all the other draw string command so they
draw to the right line instead of needing to be scrolled up. This makes
:version or the other calls feel instaneous now.

This fix is ultimately a hack and an intermediary solution before the
renderer can be replaced (since the slow CPU scrolling causes normal
usage to feel sluggish as well) by a GPU-based renderer and/or a
glyph-based one that caches the state of the texts so repeated scrolling
can be done by shuffling the glpyh data around instead of an actualy image
blit.

Fix macvim-dev#815
ychin added a commit to ychin/macvim that referenced this issue Feb 3, 2019
This fixes 10.14 Mojave's CoreText renderer taking a long time to render
:version / :ls / :! / :echo or similar commands.

This issue happened because the way Vim echos the output of those
commands is by issuing a draw calls in the pattern of "delete 1 line,
draw some text, delete another line...". Each line delete causes the
renderer to do a scroll. The pre-Mojave renderer relies on calling
scrollRect: but this doesn't work in Mojave anymore since that function
is deprecated and doesn't work in layer-backed views (which are now
mandatory). The new renderer's scroll implementation is a lot slower
since it's doing image blits on CPU.

The fix is to implement a draw command optimizer that pre-processes the
draw calls first. It works by batching together all the "delete 1 line"
calls and combine into a single "delete N lines" call and put that in
the beginning, and fixing up all the other draw string command so they
draw to the right line instead of needing to be scrolled up. This makes
:version or the other calls feel instaneous now.

This fix is ultimately a hack and an intermediary solution before the
renderer can be replaced (since the slow CPU scrolling causes normal
usage to feel sluggish as well) by a GPU-based renderer and/or a
glyph-based one that caches the state of the texts so repeated scrolling
can be done by shuffling the glpyh data around instead of an actualy image
blit.

Fix macvim-dev#815
ychin added a commit to ychin/macvim that referenced this issue Feb 3, 2019
This fixes 10.14 Mojave's CoreText renderer taking a long time to render
:version / :ls / :! / :echo or similar commands.

This issue happened because the way Vim echos the output of those
commands is by issuing a draw calls in the pattern of "delete 1 line,
draw some text, delete another line...". Each line delete causes the
renderer to do a scroll. The pre-Mojave renderer relies on calling
scrollRect: but this doesn't work in Mojave anymore since that function
is deprecated and doesn't work in layer-backed views (which are now
mandatory). The new renderer's scroll implementation is a lot slower
since it's doing image blits on CPU.

The fix is to implement a draw command optimizer that pre-processes the
draw calls first. It works by batching together all the "delete 1 line"
calls and combine into a single "delete N lines" call and put that in
the beginning, and fixing up all the other draw string command so they
draw to the right line instead of needing to be scrolled up. This makes
:version or the other calls feel instaneous now.

This fix is ultimately a hack and an intermediary solution before the
renderer can be replaced (since the slow CPU scrolling causes normal
usage to feel sluggish as well) by a GPU-based renderer and/or a
glyph-based one that caches the state of the texts so repeated scrolling
can be done by shuffling the glpyh data around instead of an actualy image
blit.

Fix macvim-dev#815
@ychin ychin closed this as completed in #840 Feb 3, 2019
@ychin
Copy link
Member

ychin commented Feb 3, 2019

This issue should now be fixed. It's not a general fix for the renderer but will make commands that echo as fast as before now (e.g. :ls, :version, :!, :echo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.14 Mojave Renderer Text rendering issues, including CoreText renderer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants