Sublime Forum

Cursor freezes / lags when typing on new M2 MacBook Pro

#1

Hi all,

I’ve been using Sublime for ~10 years, great product. Has always worked well across Windows, Ubuntu, MacOS. However, I just got a new M2 MacBook Pro, and performance is quite unusable. The cursor freezes and lags when typing or moving across lines, even on fresh restart and with no other applications running. All other applications and editors behave just fine (VSCode etc).

I’m on MacOS 13.2.1 (22D68)

Googling around, I see occasional mentions of this, most notably this hackernews thread: https://news.ycombinator.com/item?id=35249654

However, can’t find any solutions. Let me know if anyone has tips, thanks!

1 Like

#2

Does it happen in safe mode?

0 Likes

#3

Thanks for the suggestion! Unfortunately looks like the problem is still present in safe mode – I just opened a 100 line txt file in safe mode and moved the cursor up and down the document, and it was jittery and laggy.

0 Likes

#4

Does it still happen if you set "hardware_acceleration": "disabled" in settings?

1 Like

#5

I disabled it as such, and unfortunately I still see the lagginess

~ % cat /Users/daniel/Library/Application\ Support/Sublime\ Text/Packages/User/Preferences.sublime-settings
{
	"font_size": 14,
	"scroll_past_end": true,
	"hot_exit": "disabled",
	"hot_exit_projects": false,
	"hardware_acceleration": "disabled",
}

However, I also noticed this test in the default settings:

	// Enables hardware accelerated rendering. This moves rendering to your GPU,
	// allowing for faster rendering at higher resolutions. Changing this
	// setting requires an application restart to take effect.
	// - "none": Performs CPU rendering.
	// - "opengl": Uses OpenGL for rendering. Minimum required version is 4.1
	//
	// On Mac, this value is overridden in the platform specific settings.
	"hardware_acceleration": "none",

Do I need to change a MacOS specific file? I was looking at this for example: Determine if hardware_acceleration is enabled on a Mac? – I followed the instructions (View Package File -> Preferences (OSX).sublime-settings), and I see

{
	"font_face": "Menlo",
	"font_size": 12,
	"scroll_past_end": false,
	"find_selected_text": false,
	"move_to_limit_on_up_down": true,
	"close_windows_when_empty": true,
	"show_full_path": false,
	"hardware_acceleration": "opengl", // this seems worrisome
	"open_files_in_new_window": "finder_only",
}

However, maybe the preferences override the platform specific ones? (the OSX file isn’t editable).

Looking at Platform specific configurations – a bit unclear.

The first link says “If hardware acceleration is enabled, upon restart, ST would print the driver info at the very beginning of the console output.” – but I’m not sure how to get the console output when opening sublime, and a bit of searching doesn’t find any tips.

I thought maybe there might be a --verbose flag, but looks like no:

bin % pwd
/Applications/Sublime Text.app/Contents/SharedSupport/bin
bin % ls
subl
bin % ./subl --verbose .
bin %

TLDR – I think I disabled hardware acceleration, but I’m not positive, and the lag/jitteriness is still there. I tried to verify that I disabled hardware acceleration, but wasn’t able to confidently verify.

Thanks!

0 Likes

#6

No; Sublime loads the platform specific file first, and then applies yours on top. The text there is to tell you that despite what you might see in the main defaults, there is another place where that setting is going to get set, so if you want it to be a specific value, you need to set it yourself in your user settings (which always trump everything else).

The console is available from View > Show Console (there is also a key binding, looking at the menu will show you what it’s currently bound to).

0 Likes

#7

Can you enable fps logging in the console using sublime.log_fps(True) and post logs from when there’s jittering.

1 Like

#8

This is embarrassing – I opened sublime to get the logs, but was totally unable to reproduce the lag. I checked settings and re-enabled hardware acceleration, and the lag came back. Tried it a few times now, seems reproducible.

So, seems like hardware acceleration is the culprit, and for whatever reason (read: user error), I didn’t realize that the first time I tried.

TLDR: Hardware acceleration causes issues on (my) M2 mbp

0 Likes

#9

Can you please provide the logs from fps logging with hardware acceleration.

0 Likes

#10

sublime.log_fps(True)
fps: 62.4 average: 2ms
fps: 16.8 average: 3ms
fps: 102.7 average: 2ms
fps: 99.2 average: 2ms
fps: 104.7 average: 2ms
fps: 72.6 average: 3ms
fps: 34 average: 4ms
fps: 21.6 average: 4ms
fps: 11.2 average: 4ms
fps: 23.4 average: 4ms
fps: 20.7 average: 3ms
fps: 45.4 average: 3ms
fps: 88 average: 3ms

Doesn’t seem to quite capture the cursor freezing as it moves around

Also realized it only happens when I’m plugged into my external monitor (even if sublime is on my laptop screen)

0 Likes

#11

Given the rendering performance is keeping up and it’s only happening with an external monitor plugged in this is likely an OpenGL driver bug. Unfortunately this kind of performance bug is generally not something we can find a workaround for.

2 Likes

#12

Disabling hardware acceleration seems to have perfectly good performance, so I’ll just do that for now – thanks!

0 Likes

#13

I had this same issue on my M2 MBP. Starting in safe mode worked so that indicated something wrong in my normal launch. Turns out there was a “Session.sublime_session” file in the Application Support/Sublime folder that when deleted, the app performed flawlessly without any lags. It didn’t seem like anything major happened when deleting this file, but your mileage may vary.

0 Likes

#14

Deleting the session loses all your open and unsaved files, as well as a fair amount of other stuff.

The sessions is saved asynchronously so it shouldn’t be causing any performance issues unless a plugin is doing something weird. If you have a session file that’s causing issues a bug report would be much appreciated.

0 Likes

#15

Hi @bschaaf, I’m sorry but I took a quick look at the contents and there’s too much work specific stuff in there to share. But suffice to say that removing the file and relaunching did resolve my issue.

0 Likes

#16

Just created an account for this. I had the exact same situation (using external monitor with MacBook Pro M2), and this fixed it. I do not see any lag at all so software rendering should be good enough for the time being until there is hopefully a fix to re-enable GPU rendering if needed.

Thank you,

0 Likes

#17

Just found this thread. I was also experiencing the micro-freezes for a while now, on a Mac with external monitor.

Disabling the hardware acceleration seems to have fixed it.

If there is an upstream OpenGL bug, has it been reported?

0 Likes

#18

This is not related to Portables. I have the same problem on M2 Pro Desktop. Its so annoying. but I am going to try the disable hardware option. Setting the options IE copy and paste the above recommended settings into the Preferences.sublime-settings fixed the issue, which appears to me as it should be the default anyway. I nearly binned the application, because the principle of the Mac is shit should work out of the box, so dont know what happened in this case.

0 Likes