Mind Juice
  • Email
  • Twitter
  • Rss
  • About
  • Blog
Home» iDevBlogADay » How to Fix an App that Crashes in Release but not Debug

How to Fix an App that Crashes in Release but not Debug

Posted on November 30, 2011 by admin in iDevBlogADay 12 Comments

I recently submitted version 1.16 of Charmed to the App Store, which included a new OpenFeint version, and a new Tap Me SDK version.  In addition, this was the first version of Charmed to be built under any version of Xcode 4.x.

Everything seemed to go smoothly with the submission and it was soon posted to the App Store.  With over 71,000 updates in 4 days and no complaints, I thought everything was good.

Then a couple of days ago I got an email from a player saying that Charmed was crashing when starting a new game.  Then I got another email and another one.

I investigated first on my iPhone 4S, iPod touch 4th gen and iPad.  Charmed worked perfectly on all of them.  I was confused.

Then I tried my old iPhone 3G…BOOM!  It crashed instantly.

Debug This!

I connected the iPhone 3G to my iMac and ran Charmed in Debug mode.  No crash.  Damn!  I hate these kinds of problems!

I tried multiple times with the network connected and disconnected, with OpenFeint enabled and disabled, after upgrading from version 1.15 and after a fresh install.  It worked fine every time.

I wasn’t sure where to look next, so I started to think about what the differences could be, and decided to check the Build Settings.  The new Build Settings dialog in Xcode 4 was a big help.  Being able to see the different settings for Debug and Release mode at the same time is a great feature.

One of the differences that jumped out at me was the Optmization Level setting.  The Debug version was set to None [-O0], while the Release version was set to Fastest, Smallest [-Os].

I changed the Debug setting to Fastest, Smallest [-Os] and BOOM, it crashed on the iPhone 3G every time I ran it.  Switching it back to None [-O0] brought back the correct behavior.

I did a Google search and found a question on stackoverflow.com saying exactly the same thing.

After some testing to ensure that performance was not majorly affected, and that it ran on all my devices, I submitted version 1.17 of Charmed to iTunesConnect.

The world is safe again for people to play Charmed on older devices (the update is now live on iTunes).

I’m All Thumbs

I wanted to get a quick fix out there ASAP, so the above change was good enough for now, however, during my investigations I found out about the Thumb instruction set.

Basically, Apple CPUs understand two instructions sets, the normal ARM instructions and a reduced size instruction set called Thumb.  The one limitation of the Thumb instruction set is that it has poor floating point performance.  So you trade off slower floating point for smaller executable size.

To complicate matters though, Apples armv7 processors support Thumb-2, which has good floating point performance.

The solution appears to be to add a build setting that builds the ARM instructions for armv6 devices for older devices, but uses Thumb-2 for the new armv7 devices.

I don’t yet know if building for the ARM instruction set on armv6 devices will fix my code generation problem, but I’ll be giving it a try sometime soon.

Lesson Learned

From now on, when I am in the final testing phase, I will test with the Optimization Level set to Fastest, Smallest [-Os] in Debug mode to more closely simulate the code that will be generated & running on the user’s device.

Hopefully this will allow me to catch this type of problem in the future before it gets into customers hands.

Of course if would also be nice if Apple were to fix this code generation bug in Xcode, but given that they are not even updating iOS for these older devices, I don’t expect that they will put much effort behind this.

  • Hollance

    I’ve debugged an app that I only was able to make consistently crash on a 3G with the debugger attached. It worked fine on all other devices that I tested on. This turned out to be a memory management error where NSXMLParser was being released in its own delegate. It corrupted memory but only on the 3G with the debugger enabled did it actually cause a crash. So you might want to double check your app for memory management issues as well. :-)

  • http://www.alexcurylo.com Alex Curylo

    You compiling with Xcode 4.2.1? According to posts on devforums.apple.com it’s supposed to sort the LLVM thumb issue.

  • http://twitter.com/MindJuiceMedia Ken Carpenter

    I may still be on Xcode 4.2…will check tonight.  Thanks for the tip.

  • Pingback: cool caravans

  • Tncamper12

    I love this game. Do you have any plans for an Android version? That would make me sooooo happy.

  • http://twitter.com/MindJuiceMedia Ken Carpenter

    Glad you like the game!  Unfortunately the game is written using a lot of Apple-only technologies, so it would be a nearly complete rewrite to move it to Android.  Almost 100% of the graphics and sounds could be reused though.

    I’m not ruling it out, and if I do it, it would be as a separate project farmed out to another developer.

    If it happens, you’ll read about it here. :-)

    Thanks.

  • Pingback: cheap guest beds

  • Pingback: jason

  • Pingback: Martin

  • Pingback: womens clothing

  • Pingback: Iphone Slots

  • Pingback: fight night 2004 xbox

Support

Email us at: info@mindjuice.net

Please be sure to let us know which app you are asking about. Thanks!

Our Games & Apps







Recent Posts

  • Pre-Announcing My Next Game: Spellchemy
  • 2011: The Year In Review
  • Charmed: RewardsDen Edition Lets Players Earn Free Gift Cards
  • How to Fix an App that Crashes in Release but not Debug
  • Towards a Solution to App Store Clutter

Blog Archive

iDevBlogADay

RSS Feed

Login

Login

Mind Juice Media is a game development company formed by industry veteran Ken Carpenter. Mind Juice is currently focused on the mobile market, and in particular, the iPhone, iPod touch and iPad.

Info coming soon.

More info here.

© 2012 Mind Juice Media Inc.