问题
On Mac OS 10.8 I'm getting the following warning in my app:
CoreAnimation: warning, deleted thread with uncommitted CATransaction;
It suggests turning on CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces, which I did.
This is the top of my backtrace:
0 QuartzCore 0x00007fff88a84b95 _ZN2CA11Transaction4pushEv + 219 1 QuartzCore 0x00007fff88a8476d _ZN2CA11Transaction15ensure_implicitEv + 273 2 QuartzCore 0x00007fff88a8bb6a _ZN2CA5Layer12begin_changeEPNS_11TransactionEjRP11objc_object + 44 3 QuartzCore 0x00007fff88a8cb4e _ZN2CA5Layer10set_boundsERKNS_4RectEb + 452 4 QuartzCore 0x00007fff88a8c908 -[CALayer setBounds:] + 189
Does anyone know what this warning is, and how to avoid it?
回答1:
I found that wrapping the offending code an explicit CATransaction
with actions disabled made the warning go away.
i.e.
[CATransaction begin];
[CATransaction setDisableActions:YES];
layer.bounds = CGRectMake(0, 0, 1000, 1000);
[CATransaction commit];
来源:https://stackoverflow.com/questions/11882931/coreanimation-uncommitted-catransaction-warning