0

When I test my app on my iPad I can consistently and reliably get it to crash. When it does, I get an EXC_BAD_ACCESS error in main, and the root cause is far from obvious. I have tried the following steps to try to shed more light on it:

  1. I have enabled zombies. This doesn't seem to have had any affect at all in the output, which makes me think this is not a zombie issue (but clearly I could be wrong).
  2. I have add an exception breakpoint, but when the app crashes, the exception breakpoint doesn't kick in, and all I get is the standard green arrow next to line 16 of main.
  3. I have run the Analyzer and corrected the few minor error that were revealed there. Still, no effect.
  4. I have confirmed that the same problem is occurring for two of my testers who receive the build via test flight.
  5. I have performed a 'Clean' as well as a 'Clean Build Folder'

Here is whats especially weird. When I test on the iPad the app crashes consistently. When I test in a simulator it will not crash no matter what I do. So if it IS a zombie I am at a loss as to how to discover which object need retained better. Further, if I test on my iPhone, the app also does not crash.

Where the crash occurs: In the app, I have a number of sprite nodes that display information, when I touch one of them (actually, what I am touching is a child sprite made to look like a cancel button), what is supposed to happen is that I remove the cancel button's parent from its parent with:

[[self parent] removeFromParent];

Pic of call stack:

enter image description here

There is nothing in the console in the main xcode window, but this is in the console of the device (from the organizer window:

Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 69 +0.000164 sec [0254/060b]: far -> 788
Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 70 +0.000079 sec [0254/060b]: esr -> 796
Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 71 +0.000081 sec [0254/060b]: exception -> 800
Apr 10 08:50:42 Roberts-iPad backboardd[31] <Error>: HID: The 'Passive' connection 'Bubble Fit' access to protected services is denied.
Apr 10 08:50:43 Roberts-iPad backboardd[31] <Warning>: CoreAnimation: updates deferred for too long
Apr 10 08:50:57 Roberts-iPad lockdownd[25] <Notice>: 01cdc000 _select_socket: receive secure message timeout!
Apr 10 08:50:57 Roberts-iPad lockdownd[25] <Notice>: 01cdc000 _receive_message: walk away - non-SSL 1

Up until yesterday I thought I was very, very close to shipping :P I would appreciate any advice on how to shed more light on what the root cause of this exception is. Thanks!

UPDATE: As LearnCocos2D points out below, I may very well have the same SpriteKit bug he links to. The suggestion is to override removeFromParent. I tried this, but it produces an error:

- (void)removeFromParent
{
    [self removeFromParent];
    self = nil;

    [super removeFromParent];
}

The error it produces is that self cannot be assigned to outside of init. How should I rewrite that?

zeeple
  • 5,509
  • 12
  • 43
  • 71
  • 1
    At what point does the app crash? When presenting a scene, backgrounding, adding a node to a scene...? – MassivePenguin Apr 10 '14 at 06:21
  • 1
    call stack? anything in the debug log? – CodeSmile Apr 10 '14 at 07:40
  • Try using it on another iPad, just to be sure there is no problem with the one u r using. – ZeMoon Apr 10 '14 at 13:31
  • I would delete the app from the iPad, in Xcode do Product->Clean and then try it again on the iPad. If that doesn't work, post the crash log messages so people can see what's going on. – sangony Apr 10 '14 at 14:10
  • I have done a product clean as well as a Clean Build Folder but the problem persists, also I know it is not just my iPad because two of my testers have reported the same problem :( – zeeple Apr 10 '14 at 15:40
  • I am going to add some more info to the question description including a snapshot of the stack trace (not sure how to simply C&P it), and hopefully, some useful info form the console. – zeeple Apr 10 '14 at 15:42
  • @LearnCocos2D When you say 'debug log', are you talking about the Device Logs accessible through the Organizer window? If so, there is no corresponding crash report at all in that location. If this is not the debug log you are referring to, could you be more specific? Thanks! – zeeple Apr 10 '14 at 16:46
  • Referring to the first 2 screenshots in the following link, the "debug area" with the "console output" where your app logs stuff and errors if you launch a debug build from within Xcode. https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode_Overview/DebugYourApp/DebugYourApp.html#//apple_ref/doc/uid/TP40010215-CH18-SW1 – CodeSmile Apr 10 '14 at 18:59
  • Also check if you may have this bug: http://stackoverflow.com/questions/22399278/sprite-kit-ios-7-1-crash-on-removefromparent – CodeSmile Apr 10 '14 at 19:00
  • Holy cow, yes, I might indeed have that bug! One problem I have with the solution though: the suggested workaround is to override removeFromParent, but how do you do that? I am posting my override in the question description above. Any suggestions? – zeeple Apr 10 '14 at 20:27

1 Answers1

0

As it turns out, this really was a bug in SpriteKit, further discussed here:

Sprite Kit iOS 7.1 crash on removeFromParent

My fix was to override removeFromParent, in the SKShapeNode subclass that contained the children that needed to be nil'ed before the parent was removed, as thus:

- (void)removeFromParent
{
    [self.addButton removeFromParent];
    [self.cancelButton removeFromParent];
    self.addButton = nil;
    self.cancelButton = nil;

    [super removeFromParent];
}

The children shape nodes are properties of the parent.

Community
  • 1
  • 1
zeeple
  • 5,509
  • 12
  • 43
  • 71