iphone status bar activity indicator spins forever

Can someone point me why this activity indicator is spinning? All apps are closed. It's starts to spin right after I'm activating wifi. Wifi turned off - activity indicator disappearing.


Usually that means that your phone is doing a heavy-weight network activity, which can mean any of the following (not exhaustive list, only most common, and, coincidentally, easiest to fix):

  • The network you've connected to needs some more configuration, and it's taking some time to get the configuration information set properly from the router (or, more likely, DNS server)
  • Your phone is polling for a lot of data to transfer - maybe there are a lot of apps to update, or you have a lot of email to sync, or you have a lot of cloud data to download
  • Your phone is trying to hit an important server, and is having trouble connecting to it (say, it's trying to poll apple servers to check for software updates and the servers in questions are down). The spinner is going to stay up for a while, until your phone gives up or gets an actual connection.

Try connecting to a reliable network (fast connection, easy internet access - ie, not something like a coffee shop network), and letting your phone figure itself out for a while (give it a good 15-20m). Try doing this a few times. If you still have the spinner problem on the good network after being connected to it for a long time, and checking your phone a few times, you might have a rarer, but also much more difficult to diagnose/fix, problem - go to the apple store and ask them to take a look :)


The Cause

I can reproduce this problem consistently on iOS 7.1.1. Just go into App Store and click the "update all" button in the updates tab. When you exit to your home screen, the activity indicator will spin in the status bar incessantly. Since the code has been wedged into the wrong state, the only way to get rid of the activity indicator is to power down your phone and boot it back up.

The Reason

This is caused by Apple developers poor programming. They properly show it when apps begin to update:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

But they fail to turn it off when the apps finish updating:

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

The way their Cocoa Touch framework is written makes it very easy for amateur developers to make this mistake, including Apple's own internal iOS development team. It's very hard to manage nested network operations that need to show the activity indicator. The correct interface for managing the activity indicator would have been to create a stack. Any time the indicator is needed, an object would be pushed onto the stack. When the operation is complete, the object would be popped from the stack. Once the stack is empty, the indicator should disappear.