• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Animation slow down
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Animation slow down


  • Subject: Re: Core Animation slow down
  • From: <email@hidden>
  • Date: Mon, 23 Mar 2009 08:58:13 -0600

Resending this because my browser messed up the formatting, apologies 
 
Hi all. I had some previous questions about Core Animation, this is not
related to that at all (so don't take the previously mentioned code and
methods into consideration).
I have a transparent window, in which I create a view, and a root layer,
and from then on just create and manage sublayers directly (code for that
below).
My problem is when I first run the app, it's very smooth (looking like
60fps). But when I leave it running for a while (sometimes after a couple
of minutes, sometimes after half an hour) it slows down, really really down
(e.g. roughly 1fps).
 
My setup is very simple: I am setting up a timer:  [NSTimer
scheduledTimerWithTimeInterval:5 target:self
selector:@selector(animateFired:) userInfo:nil repeats:YES];
animateFired does nothing other than applies simple random implicit
animation to a couple of layers (rotation, position, scale etc).
My CALayers are are drawn via delegates which load (in the delegate init)
and display PDF content (in the drawLayer - code below).

I can see from the console that the drawLayer is only being called once
(during app init) as expected.
I have no other code running and have no leaks (nothing is allocated after
init methods, the only code that runs is the timer callback which simply
sets layer properties).

I cannot understand why this slow down is, and why sometimes it's after a
couple minutes, and sometimes comes in a lot later.
Also this does not happen on my dev machine, but 3 other machines I've
tested on (which all have similar but slightly lower spec).

I am about to install xcode on the other machines as well, but was
wondering if I am missing anything (e.g. about window/view creation, other
deep system issues I need to care about. )?


Creating window and view:
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
   NSLog(@"applicationDidFinishLaunching");
   [[TransparentWindow alloc] initWithContentRect:[[NSScreen mainScreen]
visibleFrame]];
}

-(id) initWithContentRect:(NSRect)windowRect {
   NSLog(@"TransparentWindow::initWithContentRect");
   if(self = [super initWithContentRect:windowRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
{
      [self setOpaque:NO];
      [self setBackgroundColor:[NSColor clearColor]];
      [self setMovableByWindowBackground:NO];
      [self makeKeyAndOrderFront:nil];
      [self setAcceptsMouseMovedEvents:YES];

      [self setContentView:[[[NSView alloc] initWithFrame:NSMakeRect(0, 0,
windowRect.size.width, windowRect.size.height)] autorelease]];
   }
   NSLog(@"/TransparentWindow::initWithContentRect");
   return self;
}


Creating root layer:
NSSize windowSize	= [[NSApplication sharedApplication]
keyWindow].frame.size;
rootView		= [[[NSApplication sharedApplication] keyWindow] contentView];
rootView.wantsLayer	= YES;

CATransform3D sublayerTransform =
CATransform3DMakeTranslation(windowSize.width/2,
windowSize.height/2, 0); // offset (0, 0) to center of layer
sublayerTransform.m34 = -.0003;	// perspective. bigger is more
rootView.layer.sublayerTransform	= sublayerTransform;

CALayer Delegate drawRect:
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context {
   NSLog(@"PDFLayerDelegate::drawLayer %@", filename);
   CGAffineTransform m = CGPDFPageGetDrawingTransform(page,
kCGPDFArtBox, CGContextGetClipBoundingBox(context), 0, NO);
   CGContextSaveGState(context);
   CGContextConcatCTM(context, m);
   CGContextClipToRect(context, CGPDFPageGetBoxRect(page, kCGPDFArtBox));//
4
   CGContextDrawPDFPage(context, page);
   CGContextRestoreGState(context);
}





_______________________________________________

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

References: 
 >Core Animation slow down (From: <email@hidden>)

  • Prev by Date: Re: Stop NSScrollView from catching scroll events.
  • Next by Date: Re: De-Mystifying NSCell
  • Previous by thread: Core Animation slow down
  • Next by thread: NSObliquenessAttributeName, labelFontOfSize, & Italic
  • Index(es):
    • Date
    • Thread