Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3879684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:45:18+00:00 2026-05-19T22:45:18+00:00

I have a NSWindow containing a NSView with ‘Wants Core Animation Layer’ enabled. The

  • 0

I have a NSWindow containing a NSView with ‘Wants Core Animation Layer’ enabled. The view then contains many NSImageView that use are initially animated into position. When I run the animation, it is extremely sluggish and drops most of the frames. However, if I disable ‘Wants Core Animation Layer’ the animation works perfectly. I’m going to need the core animation layer but can’t figure out how to get it to perform adequately.

Can I do anything to fix the performance issues?

Here is the code:

// AppDelegate
NSRect origin = ...;
NSTimeInterval d = 0.0;
for (id view in views)
{
    [view performSelector:@selector(animateFrom:) withObject:origin afterDelay:d];
    d += 0.05f;
}

// NSImageView+Animations
- (void)animateFrom:(NSRect)origin
{   
    NSRect original = self.frame;
    [self setFrame:origin];
    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:0.20f];
    [[self animator] setFrame:original];
    [NSAnimationContext endGrouping];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:45:18+00:00Added an answer on May 19, 2026 at 10:45 pm

    It’s possible that the NSTimer is killing your performance. Core Animation has rich support for controlling the timing of animations through the CAMediaTiming protocol, and you should take advantage of that in your app. Instead of using the animator proxy and NSAnimationContext, try using Core Animation directly. If you create a CABasicAnimation for each image and set its beginTime, it will delay the start of the animation. Also, for the delay to work the way you want, you must wrap each animation in a CAAnimationGroup with its duration set to the total time of the entire animation.

    Using the frame property could also be contributing to the slowdown. I really like to take advantage of the transform property on CALayer in situations like this where you’re doing an “opening” animation. You can lay out your images in IB (or in code) at their final positions, and right before the window becomes visible, modify their transforms to the animation’s starting position. Then, you just reset all of the transforms to CATransform3DIdentity to get the interface into its normal state.

    I have an example in my <plug type=”shameless”> upcoming Core Animation book </plug> that’s very similar to what you’re trying to do. It animates 30 NSImageViews simultaneously with no dropped frames. I modified the example for you and put it up on github. These are the most relevant bits of code with the extraneous UI stuff stripped out:

    Transform the layers to their start position

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
      // ... SNIP ... //
      //Start with all of the images at the origin
      [CATransaction begin];
      [CATransaction setDisableActions:YES];
      for (CALayer *imageLayer in [[[self imageContainer] layer] sublayers]) {
        CGPoint layerPosition = [layer position];
        CATransform3D originTransform = CATransform3DMakeTranslation(20.f - layerPosition.x, -layerPosition.y, 0.f);
        [imageLayer setTransform:originTransform];
      }
      [CATransaction commit];
    }
    

    Animate the transform back to the identity

    - (IBAction)runAnimation:(id)sender {
      CALayer *containerLayer = [[self imageContainer] layer];
    
      NSTimeInterval delay = 0.f;
      NSTimeInterval delayStep = .05f;
      NSTimeInterval singleDuration = [[self durationStepper] doubleValue];
      NSTimeInterval fullDuration = singleDuration + (delayStep * [[containerLayer sublayers] count]);
    
      for (CALayer *imageLayer in [containerLayer sublayers]) {
        CATransform3D currentTransform = [[imageLayer presentationLayer] transform];
    
        CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
        anim.beginTime = delay;
        anim.fromValue = [NSValue valueWithCATransform3D:currentTransform];
        anim.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
        anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        anim.fillMode = kCAFillModeBackwards;
        anim.duration = singleDuration;
    
        CAAnimationGroup *group = [CAAnimationGroup animation];
        group.animations = [NSArray arrayWithObject:anim];
        group.duration = fullDuration;
    
        [imageLayer setTransform:CATransform3DIdentity];
        [imageLayer addAnimation:group forKey:@"transform"];
        delay += delayStep;
      }
    }
    

    I also have a video on YouTube of the example in action if you want to check it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem I have a transparent NSView on a transparent NSWindow . The view's
I have an NSWindow containing and NSImageView. I want that the user can drag
I have an NSWindow subclass (GameWindow) containing an NSOpenGLView subclass (GameView). The app is
I have an NSWindow with 2 NSViews (an NSSplitView and a custom NSView ).
I have an NSWindow which contains an NSImageView. This window gets activated everytime I
I have an NSWindow that I defined in interface builder. I want to make
I have a NSWindow that hosts a WebView that Ive hooked up to a
I have an NSWindow that shows up when you click either of two items
I have an NSBorderlessWindow subclass of NSWindow with a transparent and non-opaque background (so
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.