iPhone - Debugging a crash when you can't find it
A crash was reported in my app, Crash Pad Drums. It cites a problem with certain cymbal sounds causing a crash on an iPod 4. One problem. I can't find the crash on my iPod touch 2, and I don't have an iTouch 4.
What in the heck can I do about this?
On another note, my app is free for today. If someone could download it and find the circumstances of the crash, I'd be in your debt.
EDIT: Clarification
I can't actually cause the crash as I don't have a newer device to test on. I suspect that it's an iOS 5 issue which I am looking into now, but in the future what should I do if I'm cheapo and not willing to buy a new iTouch?
EDIT:
Console log:
2011-10-14 23:08:25.797 Crash Pad[794:12203] -[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0xec9e2e0
2011-10-14 23:08:25.798 Crash Pad[794:12203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0xec9e2e0'
*** First throw call stack:
(0x1c49052 0x21fdd0a 0x1c4aced 0x1baff00 0x1bafce2 0x16f4f0 0x15d99e 0x14e0d8 0x168d42 0x15ace2 0x5c28c7 0x5c2a31 0x5c2d45 0x1be0f4a 0x1bac665 0x1bac056 0x5c2c43 0x249c8 0x24a58 0x8a72 0x1c4aec9 0x67a299 0x67a306 0x1c4aec9 0x67a299 0x67a306 0x5b6a30 0x5b6c56 0x59d384 0x590aa9 0x28c3fa9 0x1c1d1c5 0x1b82022 开发者_StackOverflow0x1b8090a 0x1b7fdb4 0x1b7fccb 0x28c2879 0x28c293e 0x58ea9b 0x1f0d 0x1e85)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
What you've found is an Apple bug. You can easily reproduce by animating any view, like this:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
anim.duration = 0.2;
anim.repeatDuration = HUGE_VALF;
anim.autoreverses = YES;
anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.0)];
[view.layer addAnimation:anim forKey:@"throb"]; // if this isn't nil we crash on tap
Run the project. Tap the throbbing view. Crash. This code was perfectly fine on iOS 3 and iOS 4. The workaround for now is to set forKey:
to nil, but that may be unacceptable, as this argument can be important - a non-nil key means that if you later add another animation with the same key, this animation is removed, which might be exactly what you were trying to do.
I have submitted a bug report to Apple, and I suggest you do the same.
EDIT (2/3/12): Okay, Apple says this is my bug, not theirs. Since I'm supplying a transform, I need to use a key of @"transform"
, not @"transform.scale"
. Moreover, the z-value of my 3D scale transform should be 1, not 0.
Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:
(gdb) info malloc-history 0x543216
Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.
Do you have a crash log or two that you can post? That would be helpful.
Given that it is crashing on newer hardware as opposed to older, it is unlikely to be a memory related issue. Most likely, it is a timing issue related to threading; the faster device gets something done sooner and touches a data structure before something else is done with it. Given that sound playback is a constant duration across the different devices would lend further credence to this theory.
It ended up being an issue with iOS 5. I was able to narrow down the cause of the crash by commenting out various pieces of code. When in doubt, comment out.
精彩评论