Skip navigation.
 
mlNSAnimation crashing on Leopard;
FROM : Matt Budd
DATE : Tue Nov 20 00:04:29 2007

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
//--------------------------------------------------

Related mailsAuthorDate
mlNSAnimation crashing on Leopard; Matt Budd Nov 20, 00:04
mlRe: NSAnimation crashing on Leopard; Matt Budd Nov 21, 17:42
mlRe: NSAnimation crashing on Leopard; Martin Redington Nov 25, 13:47
mlRe: NSAnimation crashing on Leopard;; Matt Budd Dec 20, 22:56