In the last few weeks I’ve started wondering if it was worth working on iPhone apps anymore. The iPad is easier to build an user interface for, at least in terms of real estate, and more fun to test on. More significantly all of my iPhone apps started to break down. Gravilocity did in a rather explosive manner, taking down a thousand dollar marketing attempt. But gradually I started to see complaints about iBeams too. “crash on launch WTF”, “stopped working after last update.” Occasionally iTunes Connect, apple’s app management website for developers, would report a timeout on launch, but without a stack trace, description of what it meant, or explaining anything about the devices it was happening on.
I’ve now updated Gravilocity 3 times trying to figure out these unexplained crashes. Every time I optimized and sped up the init code, fewer people reported a problem. But it never really finished off the crash. Over the weekend I think I finally realized that this was happening: http://stackoverflow.com/questions/169470/does-the-iphone-timeout-if-a-function-takes-too-long-to-execute Apple has left a wonderful little gift for the unsuspecting coder. It will never go off while debugging in xcode. On the other hand, every time you increase the resolution of your assets to make the latest iPhone 4 user happy, you’re raising the likelihood you’re going to blow up on older devices. Now once you know about this issue, it’s fairly easy to fix. Just make sure you aren’t doing lots of loading in your application delegate init code.
In my case the default openGL sample code, which I bootstrapped my infrastructure off of, creates the openGL context and then immediately draws a frame. Gradually the amount of things I do as part of the initial draw frame code got much more elaborate, (even turning on the sound detection code can take a couple of seconds). I’ve broken up what happens so that more things happen after the application “finishes launching” and now we wait for apple to approve the app to see if this really was the bug.