Skip to content

Instantly share code, notes, and snippets.

@wkrsz
Last active December 11, 2018 07:03
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wkrsz/3d5ff7f908a180b87498 to your computer and use it in GitHub Desktop.
Save wkrsz/3d5ff7f908a180b87498 to your computer and use it in GitHub Desktop.
Stop Safari hanging when selecting the address bar or opening a new tab
This shit has been bugging me for too long, so I went on a hunt and found a workaround.
The Symptoms are as follows:
* Clicking the address bar results in a 1-4 second delay
* Opening links in new tabs results in a 1-4 second delay
* +T results in a 1-4 second delay
* `PressAndHold[<pid>]: IMKServer Stall detected` is present in `/var/log/system.log` at the time of the hang.
It appears to be to do with the PressAndHold helper - the thing that shows an IOS style selection of accents when you hold a key down.
The fix may have some unwanted effects, I haven't really noticed any.
1. Reboot into system restore mode (+R immediately after boot)
2. Navigate to Utilities > Terminal
3. Enter the command `csrutil disable`
4. Reboot
5. Open Terminal
6. `defaults write -g ApplePressAndHoldEnabled -bool false && launchctl remove $(launchctl list | grep -oE 'com.apple.PressAndHold.+$')`
7. `sudo chmod 000 /System/Library/Input\ Methods/PressAndHold.app/Contents/MacOS/PressAndHold`
8. Reboot
You can choose reboot back into restore mode and issue `csrutil enable` again to re-enable rootless mode.
However, if you're constantly hacking around with bits of the OS like me, then you can leave it disabled.
Hope this helps..
@wkrsz
Copy link
Author

wkrsz commented Feb 23, 2016

@tonatiuh
Copy link

Thanks a lot!

@sirmike
Copy link

sirmike commented Jun 30, 2016

OMG, I was looking for the solution for 2 years. Did not think about looking into system.log... Thank you so much!

@luispedrofonseca
Copy link

luispedrofonseca commented Jul 5, 2016

I've been having this problem for A LONG time as well. Tried pretty much everything else. This was the only thing that worked. THANK YOU!

[EDIT]

While this solves the problem, it actually disables a feature essential to me: the ability to press and hold on a key to show special characters.
Besides that I haven't found anything else that it interferes with.
I guess I'll have to deal with the lag until Apple decides to fix this. =/

@kingds
Copy link

kingds commented Dec 11, 2018

This fixed the issue for me! Crazy that Apple have ignored this for years.

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