13

update 5 issue seems to still be happening for another user (see comment in answer below) under macOS 11.2.3.

update 4 Looks like this issue in terminal is no longer happening after updating to 11.2.3. However, there's now a similar issue in Google Chrome where having multiple tabs open and then clicking a tab does nothing, but then moving the cursor will go to that tab (the expected behavior is obviously to go the tab immediately upon clicking the tab). The "Battery" settings under System Preferences now has a checkbox to enable/disable discrete graphics switching (not sure if it was there before) but disabling switching causes the Chrome tab problem to go away.

update 3 This just happened to me again when my macbook was at 100% battery, and plugged in. Is it possible that it's not due to the graphics switching?

Update 2 Looks like this is a known bug with the hybrid graphics of my MBP, as the answer below points out. Here's another thread. Interestingly, I haven't noticed any issues in other apps like Chrome or Safari that much, just in Terminal.

Update I notice that the lag seems to happen only when running on battery. Additionally, I've observed in even when not pressing return, for example when using Vim and just navigating around with hjkl, sometimes a single keypress would seem to not register, but then the second press would "flush" of them, or alternatively waiting about 5 seconds will "flush" the first press.

original

I'm using the default terminal in Big Sur using 2019 16 inch macbook pro. I'm on a clean install, with no changed settings or installed programs. Default shell settings.

Sometimes (maybe once every 15 min or so) when I input a command in terminal (e.g. ls or cd ~/Documents), and when I hit Return on my keyboard, the terminal seems to do nothing. If I press any key again, then the Return "goes through", along with the second key I pressed. Alternatively, if I just wait 5 seconds, the Return "goes through", and everything is fine.

Has anyone else noticed this terminal lag?

9
  • No shell config besides what Apple provides to a new user account? Commented Jan 15, 2021 at 0:30
  • 1
    yes, no shell config changes.
    – xdavidliu
    Commented Jan 15, 2021 at 2:14
  • i have a 2020 intel imac running Big Sur and i get instant response using both the Terminal app and iterm 2. I use unix a lot and have not noticed a delay.
    – Natsfan
    Commented Jan 15, 2021 at 2:51
  • Are you running anything else at the same time?
    – Natsfan
    Commented Jan 15, 2021 at 2:53
  • 1
    I'm just running safari and finder, nothing else. I actually noticed this problem on my previous install of Big Sur (was happening for several weeks, about once every 15 min, at unpredictable times, and not consistently reproducible), so I did a clean install this morning, and immediately started noticing the same thing. To clarify, I get instant response about 95% of the time. The other few percent I get lag like this. It happens both in the default zsh as well as other REPL prompts, like python3 or ghci.
    – xdavidliu
    Commented Jan 15, 2021 at 5:18

4 Answers 4

6

Update: confirmed issue still happens as of macOS 11.2 RC3

Exact same behavior here on a 16" 2019 MBP, starting from when I updated to macOS 11.0 and still occurring as of 11.2 beta 2.

Able to reproduce "on demand" by typing "ls" repeatedly in both iTerm2 as well as the built in terminal.app.

Root cause seems to be the Intel graphics driver, as disabling graphics switching or connecting an external monitor (which forces discrete graphics) eliminates the issue at the cost of battery life.

11
  • interesting; I'm not able to reproduce on demand like that. For me it happens every once in a while, but usually if I repeatedly type ls, it responds instantly. How do you disable graphics switching? I looked for "energy saver" in preferences, but it's not there.
    – xdavidliu
    Commented Jan 15, 2021 at 13:35
  • It's been moved to under "battery" Commented Jan 16, 2021 at 0:12
  • I just observed this issue happening when plugged in. Does that mean it's not caused by graphics switching? Surely when plugged in, the macbook would just stick to discrete graphics, right?
    – xdavidliu
    Commented Jan 22, 2021 at 5:46
  • 1
    Plugging power in does not cause the Mac to switch to using discrete graphics. Also, you can confirm what GPU is being used at a given time by opening up activity monitor, selecting the energy tab and looking along the bottom. Keep in mind that the frequent refresh of the activity monitor window might actually prevent the issue from occurring as long as it is visible as well. Commented Jan 23, 2021 at 18:17
  • re: "frequent refresh of activity monitor may actually prevent the issue": does this qualify as a hacky workaround? Are there any drawbacks (e.g. decreased battery) of just opening activity monitor whenever I want to use terminal, just to prevent this annoying lag?
    – xdavidliu
    Commented Jan 30, 2021 at 9:46
3

I can confirm this is still an issue on Sonoma (14.0) using a 16" 2019 MacBook Pro. I observed it anytime I was in Terminal.app regardless of which host I was logged in to. It happened when I was working locally and when I had SSH'd into another host.

As others have noted, the resolution appears to be: System Settings > Battery > Options > Disable Automatic Graphics Switching.

1
  • 1
    same here, 16" 2019 MacBook Pro. Sonoma 14.6.1. Commented Sep 2 at 23:55
2

I experienced the same issue on a 2019 16-inch MacBook Pro running Ventura 13.4.1.

The issue is caused by automatic graphics switching. I noticed that the issue was present only when not connected to an external monitor; using the built-in keyboard and monitor.

Go to System Settings -> Battery -> Options and disable automatic graphics switching to resolve the intermittent keyboard delay in terminal.

-2

I rebooted my mac and that fixed the issue

2
  • I highly doubt this. Either yours is an entirely different issue, or it's the same as mine but the reboot did not actually solve it
    – xdavidliu
    Commented Jun 23, 2022 at 15:52
  • Probably a different issue indeed, but worth the try for the people who got here.
    – Xys
    Commented Jun 24, 2022 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .