NSAnimation crashing on Leopard;
NSAnimation crashing on Leopard;
- Subject: NSAnimation crashing on Leopard;
- From: Matt Budd <email@hidden>
- Date: Mon, 19 Nov 2007 16:04:29 -0700
Hello all,
We found a strange crash in our app with NSAnimation. It appears to
have something to do with the blocking mode of
NSAnimationNonBlockingThreaded.
The crash is very reproduceable, and you can do it simply with the
attached sample code. Create a new app, put a textfield on the main
window in IB, instantiate the AppController object in IB, and set it
to be the window's delegate (and hook up the text field you created).
If you then run the code and resize the window a bunch, it will crash
on you. Usually takes about 10-20 seconds of resizing. However, if I
change the NSAnimationNonblockingThreaded to NSAnimationNonblocking,
it doesn't crash and works fine. Unfortunately, my app requires each
animation to be in its own thread, so I need to use that mode.
Any ideas what is happening here? When I try it on Tiger, it doesn't
crash, but the weird thing always was that the number of threads
(from Activity Monitor) goes through the roof...it's like they never
die off when I stop and restart the animation. Does Leopard enforce a
maximum number of threads or something?
- Matt
//--------------------------------------------------
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSTextField *lblValue; //Attach this to a NSTextView in IB
NSAnimation *_oAnimator;
}
@end
@implementation AppController
- (id)init
{
if (self = [super init]) {
_oAnimator = [[NSAnimation alloc] init];
[_oAnimator setDelegate: self];
[_oAnimator setAnimationBlockingMode:
NSAnimationNonblockingThreaded];
[_oAnimator setAnimationCurve: NSAnimationEaseInOut];
[_oAnimator addProgressMark: 0.00];
[_oAnimator addProgressMark: 0.25];
[_oAnimator addProgressMark: 0.50];
[_oAnimator addProgressMark: 0.75];
[_oAnimator addProgressMark: 1.00];
}
return self;
}
- (void)dealloc
{
[_oAnimator setDelegate: nil];
[_oAnimator release];
[super dealloc];
}
- (void)windowDidResize: (NSNotification *)poNotification
{
[_oAnimator stopAnimation];
[_oAnimator setDuration: 1.0];
[_oAnimator startAnimation];
}
- (void)animation: (NSAnimation*)poAnimation didReachProgressMark:
(NSAnimationProgress)pfProgress
{
if (poAnimation == _oAnimator) {
[lblValue setStringValue: [NSString stringWithFormat: @"%f",
pfProgress]];
}
}
@end
//--------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden