Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reg: modifying layer that is being finalized....... [CALayer frame]: message sent to deallocated instance 0xe43c520

I am stuck with a very strange issue. I hope that many of you can provide me input to solve this. My application breaks quite often, but I am not able to get the exact scenario.

In Log I get following

2011-02-10 16:22:12.914 RCA-iOS[4132:8327] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.253 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.270 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.270 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.272 RCA-iOS[4132:207] *** -[CALayer frame]: message sent to deallocated instance 0xe43c520

Following is my Stack Trace. It breaks in main thread

#0  0x01978057 in ___forwarding___
#1  0x01a07b42 in __forwarding_prep_1___
#2  0x003c196a in -[UIView(Geometry) frame]
#3  0x003f5ff4 in -[UINavigationBar _getTitleViewFrame:leftViewFrame:rightViewFrame:forViews:forItemAtIndex:]
#4  0x003e5cab in -[UINavigationBar _getTitleViewFrame:leftViewFrame:rightViewFrame:forViews:]
#5  0x003f0c06 in __-[UINavigationBar layoutSubviews]_block_invoke_1
#6  0x003bdb5c in +[UIView(Animation) _performWithoutAnimation:]
#7  0x003f76bb in -[UINavigationBar layoutSubviews]
#8  0x00f59451 in -[CALayer layoutSublayers]
#9  0x00f5917c in CALayerLayoutIfNeeded
#10 0x00f5237c in CA::Context::commit_transaction
#11 0x00f520d0 in CA::Transaction::commit
#12 0x00f827d5 in CA::Transaction::observer_callback
#13 0x019e7fbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
#14 0x0197d0e7 in __CFRunLoopDoObservers
#15 0x01945bd7 in __CFRunLoopRun
#16 0x01945240 in CFRunLoopRunSpecific
#17 0x01945161 in CFRunLoopRunInMode
#18 0x02129268 in GSEventRunModal
#19 0x0212932d in GSEventRun
#20 0x0039e42e in UIApplicationMain
#21 0x00001fd0 in main at main.m:14

And Following is the Instrument`s output for NSZombie object. This points to UIKit

#   Category    Event Type  RefCt   Timestamp   Address Size    Responsible Library Responsible Caller
0   CALayer Malloc  1   25304068864 0x10837840  48  UIKit   -[UIView _createLayerWithFrame:]
1   CALayer Zombie  -1  99780847872 0x10837840  0   UIKit   -[UIView(Geometry) frame]

Nothing point to the code. Has any one faced this kind of issue? If yes please let me know following
1) When we get "Modifying layer that is being finalized" breaking issue?
2) Is is due to layer of UIView? For example (view.layer.cornerRadius) ?
3) Stack Trace points to UINAvigationBar, is there any way to override the methods and tryout some thing?

Any help is appreciated. Thanks

like image 809
D25 Avatar asked Feb 10 '11 11:02

D25


1 Answers

The error "modifying layer that is being finalized" occurs when you are trying to modify the properties of a CALayer when it is in the process of being deallocated. I've seen this happen when I've accidentally used an accessor to clear a property on a CALayer while within that layer's -dealloc method.

This may also happen within a UIView's -dealloc method if anything display-related is updated (thus touching the underlying CALayer).

In your case, it looks like you're overreleasing a UIView somewhere, due to the zombie message. The "modifying layer that is being finalized" is just a side-effect of that, because at some point you'd be updating the UIView while it's being deallocated before it should.

Turn on breakpoints, make sure you've set a breakpoint on exceptions being thrown, and run your application within the debugger. It should halt on the line where a message is being sent to an overreleased UIView, which should tell you what view is at the center of this. Then you can backtrack to find at what point you're sending one too many release messages (or have autoreleased without retaining if you need it beyond the current scope).

Because you already have evidence pointing to the UINavigationBar, check it and its associated views to make sure that you're properly retaining it.

like image 166
Brad Larson Avatar answered Oct 04 '22 18:10

Brad Larson