Why the spinning beachball?

Computers have not made us any more patient. Our ancestors may have been happy to wait a day or two for a letter in the post, or a week or so for a more substantial parcel, but we expect an email within minutes, and next day delivery.

The spinning beachball cursor is a case in point. Should it ever appear, our heart sinks, and we start cursing the app, or macOS. And if it should stay there for more than a very few seconds, we wonder whether to force quit the app altogether.

Ever since the first Mac, and the first version of the Mac operating system, Macs have been controlled by the user, and event-driven. Every app (but not command tools) has an event queue, to which macOS passes user actions such as mouse-clicks and keypresses (and much more too). macOS expects each app to process the events in its queue at a steady rate. When an app stops doing so, for whatever reason, then macOS changes the pointer to show the spinning beachball.

spinningbeachball

When this works properly, whenever the pointer is over part of that app’s interface, including any open windows, dialogs, and the menu bar, the pointer should change to the spinning beachball, until that app starts responding to its event queue once more. You can switch to use another app, which should work quite normally.

If you open Activity Monitor and select its CPU tab, you should see the % CPU figure for that app climb until it reaches 50% or more, and the CPU load chart at the foot of that window should also shoot up.

We have become accustomed to this being an indication of a problem with that app or with macOS itself, but spinning beachballs can occur repeatedly with excellently-written apps which are not in any form of distress. The most important thing to do when you see a spinning beachball is to think, not to react in a kneejerk response.

If what you have just asked that app to do is something fairly hefty or awesome, the app may just be trying to do the computation which you want it to do. Ideally, work which is going to take a while should be put into the background, or divided up so that the app can still remain responsive to events. However, that is not always possible, and not always a good deal for you as the user.

One example of this is when the app has to wait for a long process to complete, which is outside its control, on which it depends completely. It could put that in another thread, but if there isn’t anything else that you can usefully do in that app until that long process is complete, there seems little point. Apps can spread load out onto other processor cores, and try tackling long tasks in parallel, but that isn’t always possible or sensible either.

I’m currently racking my brains for a better solution in my app Woodpile, which regularly spins a beachball when you first zoom in on a specific log file. To do this, it first has to wait for a command tool to filter through hundreds of thousands, or millions, of log entries. It then has to process those in strict order, extract the date and time from each, and add those to an array. Those operations have to be done in strict sequence, which makes them very hard to run in parallel. If they’re put into another thread to run in the background, they’ll be run more slowly, increasing the delay.

A spinning beachball can also mean that an app has become unresponsive because of a bug, such as an infinite loop in which it is trapped, or it is waiting for something that will never happen. It is hard to know when that has occurred, although a glance at the live log in Console can often provide valuable clues. If it keeps recurring, then you should take a more thorough look in the log, using Consolation or Woodpile.

When you’re convinced that the app has become permanently unresponsive, the best thing to do is press Command-Option-Escape to bring up the Force Quit dialog. The app should be shown in red, and labelled as not responding. Select it, and click on the button to force it to quit. You will lose any unsaved work, but can then try to work around the problem next time. And don’t forget to tell the app’s developer as to what happened, so that they can look into the cause.

Spinning beachballs which are the result of macOS problems are more difficult to solve, as there usually isn’t anything that you can force to quit, without doing more radical surgery in Activity Monitor or Terminal’s command line. If it’s part of macOS that is at fault, you’re normally better off restarting your Mac when possible, and hoping that will sort it out.