hey there,
there was a time, i think like 2 betas ago, where CuteClips was kinda instable. The current beta is rock solid compared to the previous one. The reason for this instability is that the preview if certain clips was implemented wrong. But it is hard to track bugs down when you can’t reproduce the crash.
What I needed was the data that CuteClips failed to process, so I needed a simple way to have people send me their data if CuteClips crashed. I created the BSJobList and the user was easily able to send me the crashlog and/or the clip-data.
That part works, people are sending me a lot of crash reports now. The downside (or upside) is that these crash reports are not current. That is, they are from crashes of previous versions. The problem that has arisen is that CuteClips thinks that it crashed, while maybe the whole system crashed. How should it know? it simply checks if it was quit properly.
So the obvious solution to track crashes, by setting some preference value to
YES
when your app quits is not the best idea. It is simple, and it’s working, but it has too many false positives.
I came up with another approach… instead of storing that we didn’t crash, lets do it the right way and store that we actually did crash.
I searched around a bit and soon found out that
signal()
should be the right point to start working. I tried to add my own signal handler and it worked just fine, i was notified when the crash happend. The downside was that I didn’t see the crashlog anymore. The fix was kinda simple, you just remove the signal handler and raise the signal again.
So registering the signal handler is done with:
signal(SIGBUS,crashHandler);
signal(SIGSEGV,crashHandler);
and the crashHandler looks like this:
void crashHandler(int num)
{
printf("we just crashed with signal: %i",num);
// reset the old signal handler
signal(num,0);
raise(num);
}
yup, it’s that simple… and to make things even better, I created a bundle from it and uploaded it to Codebeach, so that you can just add the bundle to your application and you’re all set. The usage is fairly simple, just use this code:
NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"BSCrashNotifier" ofType:@"bundle"]];
Class crashNotifierClass = [bundle principalClass];
if (crashNotifierClass)
{
[crashNotifierClass onCrashSend:@selector(weCrashed:) to:self];
}
else
{
NSLog(@"couldn't load bundle");
}
and:
- (void)weCrashed:(int)signalNumber
{
NSLog(@"we crashed: %i",signalNumber);
}
[BSCrashNotifier on CodeBeach.org]
Have fun
Karsten
p.s. I just wrote this post in MarsEdit, nice tool, works great