Skip to content

MacVim occasionally stops rendering text after sleep #1164

@mattooca

Description

@mattooca

I've been experiencing issue #1068 (where syntax highlighting turns off in existing MacVim windows when computer wakes from sleep). I also recently noticed a new issue where all text occasionally disappears in all open MacVim windows. I think the trigger is either waking the laptop from sleep or attaching / detaching external displays.

The problem occurs every two days or so, and impacts both windows that were already open and any new windows opened after. I can resolve the problem by quitting and restarting MacVim, but I often have many open windows so prefer to find a fix.

I'm currently using MacVim 8.2.2164 (169), running on OS X 10.15.7. I think this issue first appeared after the previous MacVim update (I tried updating when I first noticed the problem to see if it would resolve the issue, but no luck).

Attached image shows a new MacVim window opened up after the issue starts. The only visible text is up on the title bar, the VIM splash screen doesn't show up.

image

Activity

ychin

ychin commented on Jan 12, 2021

@ychin
Member

Can you try running with a clean vimrc (by doing mvim --clean), and show me the settings you have by doing defaults read org.vim.MacVim | grep MM?

Also, if you say resize the window, would it have fixed the problem?

mattooca

mattooca commented on Jan 12, 2021

@mattooca
Author

Settings:

    MMAutosaveColumns = 230;
    MMAutosaveRows = 56;
    MMCurrentPreferencePane = General;
    MMTopLeftPoint = "{927, 1057}";

I'll try starting with mvim --clean next time the problem occurs.
Resizing windows did not make a difference, but I tried disconnecting and reconnecting the external display and found that the problem eventually went away (not right after reconnecting but a minute or so later).

mattooca

mattooca commented on Jan 12, 2021

@mattooca
Author

Problem recurred just now, I tried opening a new window with 'mvim --clean' but see the same problem in that new window. The geometry is different (230x56 instead of my default 120x56) and the color scheme is a bit different, but it has the same problem as a window opened with just 'mvim'.

This time I waited for a while rather than restarting MacVim or detaching/reattaching the external display. The problem went away on its own after about 5 minutes, although at first it only rendered the top line of each file. Additional lines appeared as I moved the cursor up or down to each line...

schveiguy

schveiguy commented on Feb 3, 2021

@schveiguy

Having the same problem. This is quite annoying, as I frequently have 4 or 5 windows open, with 2-5 buffers each. And trying to save things is hard because I can't see anything I'm typing. I've seen it go away once, but most of the time I end up restarting it.

Another tidbit, this doesn't happen to me only when waking from sleep (I think). When this happens while I'm editing, it does not remove the existing rendered text until I move my cursor around in the file, and then every line the cursor touches is blanked. If I hit ctrl-L, it blanks the whole window's text.

Attached is a pic of one vim window I hit ctrl-L on with multiple buffers, and another one behind it where I just started to move around (you can see the area around the cursor is blank).
Screen Shot 2021-02-03 at 5 33 11 PM

ychin

ychin commented on Feb 9, 2021

@ychin
Member

Huh that's annoying… @schveiguy can you also post your result of defaults read org.vim.MacVim | grep MM? Also, what kind of Mac are you using? And also, what font are you using?

Also, for both @schveiguy and @mattooca , do your monitors support retina display? Or do you switch between retina and non-retina? I'm mostly just grasping at straws here since I can't seem to repro the issue.

added this to the snapshot-170 milestone on Feb 9, 2021
timothy-knox

timothy-knox commented on Feb 10, 2021

@timothy-knox

I'm seeing the same problem. I'm running MacVim 8.2.2164 (169) on macOS 10.15.7.

$ defaults read org.vim.MacVim | grep MM
    MMAppearanceModeSelection = 1;
    MMAutosaveColumns = 127;
    MMAutosaveRows = 43;
    MMCurrentPreferencePane = Appearance;
    MMNoTitleBarWindow = 0;
    MMTitlebarAppearsTransparent = 1;
    MMTopLeftPoint = "{0, 1027}";

It occurs without sleeping. It persists for several minutes, and running ':redraw!' does not fix it. But after five-ish minutes, the line under the cursor suddenly becomes visible again, and ':redraw!' then brings the whole screen back.

schveiguy

schveiguy commented on Feb 10, 2021

@schveiguy

I'm mostly just grasping at straws here since I can't seem to repro the issue.

It might be a good grasp. Nearly all my time I spend on my 4k attached monitor instead of my retina screen. If I had to guess, I'd say it happens mostly on my 4k screen, and it might be 100% of the time, I'm not sure.

I just spent about 5 days where I didn't have my screen, just the retina display of my macbook, and I didn't have the problem happen, but that's not really a meaningful detail, as it doesn't happen with any specific regularity.

My font is Menlo 14 point.

Here is the result of that defaults command:

    MMAutosaveColumns = 170;
    MMAutosaveRows = 83;
    MMCurrentPreferencePane = General;
    MMLastWindowClosedBehavior = 2;
    MMTopLeftPoint = "{1817, 1522}";
    MMZoomBoth = 1;
schveiguy

schveiguy commented on Feb 10, 2021

@schveiguy

I did just notice that Macvim supports dark mode, I was on the "evening" setting for colors, because it wasn't available when I started using dark mode. I just switched back to the default scheme, and maybe this will make a difference?

Edit: eh, I went back. The blue that is used for the tildes at the bottom for the default scheme is hard on the eyes.

ychin

ychin commented on Feb 10, 2021

@ychin
Member

The default MacVim color scheme never got updated for dark mode and doesn't work well under it. I need to fix it… Anyway that's a different issue.

mattooca

mattooca commented on Feb 10, 2021

@mattooca
Author

Regarding monitors, this is happening on a Macbook Pro with Retina display, but I usually have it attached to one or two lower-resolution external displays. The problem is happening right now, I tried dragging MacVim windows to different monitors but it makes no difference.
One other funny detail: it looks like the open / close parentheses syntax highlighting still works, see the little blue box in attached screenshot.

Screen Shot 2021-02-10 at 9 22 04 AM

ychin

ychin commented on Feb 11, 2021

@ychin
Member

I'm still struggling to repro this (even with an external 4K monitor), but if you see this again, try to change the font / font size. You could just do that by doing <cmd>- or <cmd>+ to quickly toggle font sizes. I think it would reset the font cache which would bring the text rendering back which should allow you to keep working.

Also, if changing font/font size does indeed solve the issue, let me know as that would confirm what I think is going wrong.

ychin

ychin commented on Feb 12, 2021

@ychin
Member

@mattooca can you clarify what you meant by this?

Attached image shows a new MacVim window opened up after the issue starts. The only visible text is up on the title bar, the VIM splash screen doesn't show up.

Are you saying that you saw that all of MacVim lost text rendering, then you opened a new window (either by Cmd-N or using the menu)? Or are you saying you already had a new window opened with text working, and then it lost its text rendering?

mattooca

mattooca commented on Feb 12, 2021

@mattooca
Author
mattooca

mattooca commented on Feb 12, 2021

@mattooca
Author

The problem recurred this morning, and I tried a few things.
Changing font, changing font size, going into full screen mode, changing the color scheme, and opening up new windows: none of those fixed the issue.

However, disconnecting the external display did fix the problem. Text showed up again on all open windows almost immediately. The text stayed visible when I then reconnected to the external display, at least so far (I tried disconnecting about 10 minutes ago).

47 remaining items

s4y

s4y commented on Mar 24, 2021

@s4y
Contributor

I'm sorry for the delay in getting to this, all. The linked pull request should fix it.

ychin

ychin commented on Mar 24, 2021

@ychin
Member

memory_pressure

That's a nice trick! I'll keep that in mind next time. Also, thanks for looking into this.

ychin

ychin commented on Mar 24, 2021

@ychin
Member

Ok this should be fixed! Thanks for the PR. Played around with it with the memory_pressure tool and confirmed the behavior and also that it's fixed.

One of those things that if we switched to ARC instead of reference counting we may have avoided this bug :/ (but then this is a CoreFoundation object, so maybe there may still be chances to have screwed this up due to how you need to specify how the bridging works)

s4y

s4y commented on Mar 25, 2021

@s4y
Contributor

One of those things that if we switched to ARC instead of reference counting we may have avoided this bug :/ (but then this is a CoreFoundation object, so maybe there may still be chances to have screwed this up due to how you need to specify how the bridging works)

@ychin This was making me think about ARC, too. I have some interest in investigating it; is there any history around talking about/trying to switch to ARC?

ychin

ychin commented on Mar 25, 2021

@ychin
Member

@s4y I think there is a lack of history of trying to switch to ARC :). But no I don't know what the history is. I think we just never looked into it, and since MacVim tends to follow the Vim philosophy of backwards compatibility, it takes a while before we are ahead enough to be able to say "we can support ARC" without breaking backwards compatibility.

Also, it's just not the kind of thing that brings immediate improvements, even though it does help prevent random memory leaks and potential retain bugs like this one.

I'm not really opposed to switching over. I was hoping to take a look at some point in the future, but if you want to investigate it that's totally fine. FWIW the new tabs PR (#1120) is using ARC, and I explicitly OKed it. No point in making a new project that uses manual reference counting.

ychin

ychin commented on Mar 30, 2021

@ychin
Member

@s4y, if you want to look into ARC, please use #1182 instead of this issue.

schveiguy

schveiguy commented on Mar 30, 2021

@schveiguy

FYI I recently updated to Big Sur and haven't seen this problem since (still on build 170). But it seems I probably won't see it again, thanks for all the support!

ekortright

ekortright commented on Mar 31, 2021

@ekortright

I am still seeing this problem on MacOS Catalina (10.15.7) with retina display and an external monitor. My MacVim is Custom Version 8.2.2576 (170).

MacVim seems to render everything correctly when I start it up, but after it has been running for a while, any new windows (e.g., when trying to edit a file from the command line using mvim) pop up with no visible text anywhere.

The only way to fix the problem is to quit MacVim and start it again.

Please let me know if I can provide any other information.

graywh

graywh commented on Mar 31, 2021

@graywh

@ekortright Note that this was committed just a week ago and snapshot 170 is 3 weeks old.

ychin

ychin commented on Mar 31, 2021

@ychin
Member

Yeah I need to push an update with this fix. Will try to do tonight. Trying to go over other changes that went in and make sure they are ok.

added a commit that references this issue on Apr 1, 2021
ychin

ychin commented on Apr 1, 2021

@ychin
Member

The update has been pushed so if you get the latest version it should be good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RendererText rendering issues, including CoreText renderer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @graywh@tomp@s4y@eirnym@schveiguy

      Issue actions

        MacVim occasionally stops rendering text after sleep · Issue #1164 · macvim-dev/macvim