iOS 7 Support

Updated to the beta version of Air 3.9 SDK today and did a new build to attempt to fix the super-cool bug where users are presented with a dialog asking them to enable the microphone the first time a sound is played. Now that sure looks professional! The new SDK did fix the bug thankfully!

Everything else seemed fine on iOS 6 and iOS 7 and then I tested bringing up Notification Center…crash. Then I attempted an in app purchase…crash. Then restoring purchases…crash. Then simply backgrounding the game by hitting the home button…crash. What gives?

After scratching my head for a few minutes, wondering what I could’ve done to have broken everything so badly, I was able to retrieve the error message from the crash log: “The Stage3D API may not be used during background execution on this operating system”. Hmm, interesting, didn’t Adobe *just* finish adding support for exactly this issue? And I certainly don’t recall turning on background execution of Stage3D content. Curious.

A quick browse of the Starling forums led me to a post about the issue I was encountering. So it turns out that Adobe is aware of the issue and it should likely be part of the next prerelease. Cool. But what to do in the meantime? Luckily Daniel (the super-awesome author of the Starling framework!) already created a quick fix for the issue. All it requires is passing true to the call to starling.stop when Event.DEACTIVATE fires.

I updated my Starling source, tested it out, and…success! Notification center now works again, as does backgrounding the game. Then I tried in app purchases…crash. Same error as before. “The Stage3D API may not be used during background execution on this operating system”. But I’m not using it! Or at least I’m not trying to!

Half an hour of digging through in app purchasing code, double-checking callbacks, and adding a ton of debug logging, the problem is…my custom dialog/popup. Ouch. See, I don’t like to just leave players hanging when they’re waiting for a purchase or to restore purchases, so I show a super-spiffy “please wait for the purchase to complete…” dialog. As soon as I get the callback from StoreKit that the purchase succeeded, failed, or was cancelled, I dismiss the dialog. A little debugging later and I realize that I’m dismissing the dialog BEFORE starling.start is called, which kicks off disposal of the dialog, which results in a vertex buffer being disposed, which means that…yeah okay, so it is me that is attempting to do something with Stage 3D while the game is still in the background. Oops.

The fix was a bit messy, but simple: if a “close dialog” request is received and starling is not currently started, set a flag in the dialog manager and do nothing. Then, as soon as the app is activated, and starling is started, tell the dialog manager to close any open dialogs but only if that flag is set (otherwise we’d auto-dismiss any other dialog that could be active, which could be the user attempting to delete their save file, purchase their way past a quest, etc.). All good.

So that’s the extent of my iOS 7 woes. Pretty good actually, really just a few hours of debugging and forum browsing. Bring on iOS 8! 😉

Leave a Reply

Your email address will not be published. Required fields are marked *