CABasicAnimation causes crash on close/order out of window
CABasicAnimation causes crash on close/order out of window
- Subject: CABasicAnimation causes crash on close/order out of window
- From: Volker in Lists <email@hidden>
- Date: Tue, 31 Mar 2009 18:19:15 +0200
Hi list,
a similar problem was already reported with no answers in january (?)
2009 - layers with CIFilter animations running may crash the app on a
window close call. If the animation is not running, no crash happens.
I have a Layer-Backed NSScrollView displaying a couple of layers with
datapoints. A selection CALayer created along the lines of the
CoreAnimation menu example from Apple's documentation is used to mark
the currently selected data layer. The selectionLayer has a "never-
ending" CIFilter animation set (pulsatingAnimation = CIBloom Filter).
The selectionLayer is added with Filter and Animation in the
showWindow method of the controlling NSWindowController. The window
controller is responsible for managing all my layers. When I don't add
the animation to the selectionLayer I don't get a single crash. If I
remove the animation before the window closes, the crash is still
happening.
In more detail the setup and parts of the code:
In IB I have set up a NSScrollView with WantsAnimationLayer clicked. I
have a NSView as document view added via IB to it. I create a
rootLayer (NSTiledLayer) where I add all my data layers to. These are
of full height and approx. 30 to 60 pixels wide. The whole view can
stretch further then 6000 pixels in width. For easier visualization a
tree:
NSScrollView (LayerBacked)
NSView (IB created)
rootLayer (NSTiledLayer) (from here on all created in code)
selectionLayer (with CIFilter and Animation)
dataLayer (NSTiledLAyer)
dataSub1
dataSub2
....
When closing the window I regularly encounter a crash on thread 3 or
thread 4 usually caused by a call to CAViewUpdate. It raises an
EXC_BAD_ACCESS; rarely it is a malloc error... but as I repeat later,
I have tried to retain most/all objects to test for a retain problem.
The app is btw not gc'ed.
example backtrace (thread3)
#0 0x26c2de9e in gldGetTextureLevel
#1 0x26c2fffd in gldGetTextureLevel
#2 0x26c30519 in gldGetTextureLevel
#3 0x26c27e20 in gldGetTextureLevel
#4 0x26b7c584 in gldGetTextureLevel
#5 0x26b7c73e in gldGetTextureLevel
#6 0x26c27b51 in gldGetTextureLevel
#7 0x26c27d50 in gldGetTextureLevel
#8 0x26be0ed1 in gldGetTextureLevel
#9 0x26977ded in gleRenderSmoothQuadsFunc
#10 0x26a05d83 in gleDrawArraysOrElements_ExecCore
#11 0x26a06cc8 in gleDrawArraysOrElements_IMM_Exec
Code snippet for selection layer creation - more or less along Apples
example code:
if (!selectionLayer || selectionLayer == nil) {
selectionLayer=[[CALayer layer] retain];
selectionLayer.bounds=CGRectMake(0.0,0.0,0.0,0.0);
selectionLayer.borderWidth=2.0;
selectionLayer.borderColor=CGColorCreateGenericRGB(1.0f,.5f,0.5f,
1.0f);
selectionLayer.cornerRadius=2.0;
selectionLayer.zPosition = -1;
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:7.0]
forKey:@"inputRadius"];
[filter setValue:[NSNumber numberWithFloat:0.0]
forKey:@"inputIntensity"];
[filter setName:@"pulseFilter"];
[selectionLayer setFilters:[NSArray arrayWithObject:filter]];
[selectionLayer addAnimation:[self pulseAnimation]
forKey:@"pulseAnimation"];
[[layerContainer layer] addSublayer:selectionLayer];
}
- (CABasicAnimation*)pulseAnimation
{
CABasicAnimation* pulseAnimation = [CABasicAnimation animation];
pulseAnimation.keyPath = @"filters.pulseFilter.inputIntensity";
pulseAnimation.fromValue = [NSNumber numberWithFloat: 0.0];
pulseAnimation.toValue = [NSNumber numberWithFloat: 1.0];
pulseAnimation.duration = 1.0;
pulseAnimation.repeatCount = 1000.0f;
pulseAnimation.autoreverses = YES;
pulseAnimation.timingFunction = [CAMediaTimingFunction
functionWithName:
kCAMediaTimingFunctionEaseInEaseOut];
return pulseAnimation;
}
Any ideas? What am I missing? I already ruled out any problems do to
retain of objects by overretaining the layers, filters and animation I
created in code. Even so, when added via the above calls, all these
objects should be retained by their hosting layer - be it layer itself
or animations... am I mislead by toggling animation on/off and
changing crashing to not-crashing by doing so? The window is not set
to "ReleaseWhenClosed", so it stays available as well. It all smells
nevertheless like a retain problem :-(
Volker
_______________________________________________
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