ios - Crash in a CAKeyframeAnimation for animating a view along a path -


i have code animate uiview: zoom down while animating along path.

it crashes error below (reproducible: always):

coregraphics`cg::path::apply(void*, void (*)(void*, cgpathelementtype, cgpoint const*)) const: 0x1055c06:  pushl  %ebp 0x1055c07:  movl   %esp, %ebp 0x1055c09:  subl   $24, %esp 0x1055c0c:  movl   8(%ebp), %eax 0x1055c0f:  movl   (%eax), %ecx 0x1055c11:  movl   (%ecx), %eax 0x1055c13:  movl   16(%ebp), %edx 0x1055c16:  movl   %edx, 8(%esp) 0x1055c1a:  movl   12(%ebp), %edx 0x1055c1d:  movl   %edx, 4(%esp) 0x1055c21:  movl   %ecx, (%esp) 0x1055c24:  calll  *64(%eax) 0x1055c27:  addl   $24, %esp 0x1055c2a:  popl   %ebp 0x1055c2b:  ret     

i think comes method below (pathanimationwithstartpoint:), if don't add cakeyframeanimation returned it, i.e., just:

[group setanimations:@[ zoomanimation ]]; 

instead of

[group setanimations:@[ zoomanimation, pathanimation ]]; 

it runs without crashing.

- (cakeyframeanimation *) pathanimationwithstartpoint:(cgpoint) startpoint {     cgpoint endpoint = self.showapplicationtourbutton.center;      cgfloat xdistancebetweenstartandendpoints = abs(startpoint.x - endpoint.x);     cgfloat yofhighestpointofcurvepath = endpoint.y - 250;      cgpoint controlpoint1 =  cgpointmake(startpoint.x + 1.0f / 3.0f * xdistancebetweenstartandendpoints, yofhighestpointofcurvepath);     cgpoint controlpoint2 = cgpointmake(startpoint.x + 2.0f / 3.0f * xdistancebetweenstartandendpoints, yofhighestpointofcurvepath);      cgmutablepathref curvedpath = cgpathcreatemutable();      cgpathmovetopoint(curvedpath, null, startpoint.x, startpoint.y);     cgpathaddcurvetopoint(curvedpath, null, controlpoint1.x, controlpoint1.y, controlpoint2.x, controlpoint2.y, endpoint.x, endpoint.y);       cakeyframeanimation *pathanimation = [cakeyframeanimation animationwithkeypath:@"position"];     pathanimation.path = curvedpath;     cgpathrelease(curvedpath);        pathanimation.calculationmode = kcaanimationpaced;     pathanimation.fillmode = kcafillmodeforwards;     pathanimation.removedoncompletion = no;       return pathanimation; } 

backtrace:

* thread #1: tid = 0x1a03, 0x01055c11 coregraphics`cg::path::apply(void*, void (*)(void*, cgpathelementtype, cgpoint const*)) const + 11, stop reason = exc_bad_access (code=2, address=0x0)     frame #0: 0x01055c11 coregraphics`cg::path::apply(void*, void (*)(void*, cgpathelementtype, cgpoint const*)) const + 11     frame #1: 0x00f5d090 coregraphics`cgpathapply + 64     frame #2: 0x01838c68 quartzcore`ca::render::path::new_path(cgpath const*, bool) + 158     frame #3: 0x018c3493 quartzcore`-[cakeyframeanimation _setcarenderanimation:layer:] + 176     frame #4: 0x018c3b2c quartzcore`-[cakeyframeanimation _copyrenderanimationforlayer:] + 68     frame #5: 0x018c6f12 quartzcore`-[caanimationgroup _copyrenderanimationforlayer:] + 241     frame #6: 0x018df547 quartzcore`ca::layer::commit_animations(ca::transaction*, double (*)(ca::layer*, double, void*), void (*)(ca::layer*, ca::render::animation*, void*), void (*)(ca::layer*, void**, void*), void*) + 641     frame #7: 0x01855520 quartzcore`ca::context::commit_layer(ca::layer*, unsigned int, unsigned int, void*) + 94     frame #8: 0x018d87fa quartzcore`ca::layer::commit_if_needed(ca::transaction*, void (*)(ca::layer*, unsigned int, unsigned int, void*), void*) + 330     frame #9: 0x018d877e quartzcore`ca::layer::commit_if_needed(ca::transaction*, void (*)(ca::layer*, unsigned int, unsigned int, void*), void*) + 206     frame #10: 0x01856667 quartzcore`ca::context::commit_transaction(ca::transaction*) + 1775     frame #11: 0x01857227 quartzcore`ca::transaction::commit() + 395     frame #12: 0x018f9b17 quartzcore`+[catransaction commit] + 52     frame #13: 0x000399bf myapp`-[homeviewcontroller catchtourscrollviewscreenshotviewandanimateittobutton](self=0x0b4e5210, _cmd=0x006f381a) + 1903 @ homeviewcontroller.m:197     frame #14: 0x0391f663 libobjc.a.dylib`-[nsobject performselector:] + 62     frame #15: 0x0003c383 myapp`-[nsobject(self=0x0b4e5210, _cmd=0x006ef5ad, selector=0x006f381a) performselectorifrespondstoit:] + 243 @ nsobject+performselectorifrespondstoit.m:22     frame #16: 0x00042506 myapp`__44-[tourviewcontroller closetourwithanimation]_block_invoke268(.block_descriptor=0x0b6985a0, finished='\x01') + 86 @ tourviewcontroller.m:419     frame #17: 0x01af0df6 uikit`-[uiviewanimationblockdelegate _didendblockanimation:finished:context:] + 223     frame #18: 0x01ae3d66 uikit`-[uiviewanimationstate senddelegateanimationdidstop:finished:] + 237     frame #19: 0x01ae3f04 uikit`-[uiviewanimationstate animationdidstop:finished:] + 68     frame #20: 0x12b6ff28 uikit`-[uiviewanimationstateaccessibility(safecategory) animationdidstop:finished:] + 66     frame #21: 0x018df7d8 quartzcore`ca::layer::run_animation_callbacks(void*) + 284     frame #22: 0x03a90014 libdispatch.dylib`_dispatch_client_callout + 14     frame #23: 0x03a807d5 libdispatch.dylib`_dispatch_main_queue_callback_4cf + 296     frame #24: 0x03f3eaf5 corefoundation`__cfrunlooprun + 1925     frame #25: 0x03f3df44 corefoundation`cfrunlooprunspecific + 276     frame #26: 0x03f3de1b corefoundation`cfrunloopruninmode + 123     frame #27: 0x044c67e3 graphicsservices`gseventrunmodal + 88     frame #28: 0x044c6668 graphicsservices`gseventrun + 104     frame #29: 0x01aa5ffc uikit`uiapplicationmain + 1211     frame #30: 0x0000285d myapp`main(argc=1, argv=0xbffff3f4) + 141 @ main.m:16     frame #31: 0x00002785 myapp`start + 53 * thread #1: tid = 0x1a03, 0x01055c11 coregraphics`cg::path::apply(void*, void (*)(void*, cgpathelementtype, cgpoint const*)) const + 11, stop reason = exc_bad_access (code=2, address=0x0)     frame #0: 0x01055c11 coregraphics`cg::path::apply(void*, void (*)(void*, cgpathelementtype, cgpoint const*)) const + 11     frame #1: 0x00f5d090 coregraphics`cgpathapply + 64     frame #2: 0x01838c68 quartzcore`ca::render::path::new_path(cgpath const*, bool) + 158     frame #3: 0x018c3493 quartzcore`-[cakeyframeanimation _setcarenderanimation:layer:] + 176     frame #4: 0x018c3b2c quartzcore`-[cakeyframeanimation _copyrenderanimationforlayer:] + 68     frame #5: 0x018c6f12 quartzcore`-[caanimationgroup _copyrenderanimationforlayer:] + 241     frame #6: 0x018df547 quartzcore`ca::layer::commit_animations(ca::transaction*, double (*)(ca::layer*, double, void*), void (*)(ca::layer*, ca::render::animation*, void*), void (*)(ca::layer*, void**, void*), void*) + 641     frame #7: 0x01855520 quartzcore`ca::context::commit_layer(ca::layer*, unsigned int, unsigned int, void*) + 94     frame #8: 0x018d87fa quartzcore`ca::layer::commit_if_needed(ca::transaction*, void (*)(ca::layer*, unsigned int, unsigned int, void*), void*) + 330     frame #9: 0x018d877e quartzcore`ca::layer::commit_if_needed(ca::transaction*, void (*)(ca::layer*, unsigned int, unsigned int, void*), void*) + 206     frame #10: 0x01856667 quartzcore`ca::context::commit_transaction(ca::transaction*) + 1775     frame #11: 0x01857227 quartzcore`ca::transaction::commit() + 395     frame #12: 0x018f9b17 quartzcore`+[catransaction commit] + 52     frame #13: 0x000399bf myapp`-[homeviewcontroller catchtourscrollviewscreenshotviewandanimateittobutton](self=0x0b4e5210, _cmd=0x006f381a) + 1903 @ homeviewcontroller.m:197     frame #14: 0x0391f663 libobjc.a.dylib`-[nsobject performselector:] + 62     frame #15: 0x0003c383 myapp`-[nsobject(self=0x0b4e5210, _cmd=0x006ef5ad, selector=0x006f381a) performselectorifrespondstoit:] + 243 @ nsobject+performselectorifrespondstoit.m:22     frame #16: 0x00042506 myapp`__44-[tourviewcontroller closetourwithanimation]_block_invoke268(.block_descriptor=0x0b6985a0, finished='\x01') + 86 @ tourviewcontroller.m:419     frame #17: 0x01af0df6 uikit`-[uiviewanimationblockdelegate _didendblockanimation:finished:context:] + 223     frame #18: 0x01ae3d66 uikit`-[uiviewanimationstate senddelegateanimationdidstop:finished:] + 237     frame #19: 0x01ae3f04 uikit`-[uiviewanimationstate animationdidstop:finished:] + 68     frame #20: 0x12b6ff28 uikit`-[uiviewanimationstateaccessibility(safecategory) animationdidstop:finished:] + 66     frame #21: 0x018df7d8 quartzcore`ca::layer::run_animation_callbacks(void*) + 284     frame #22: 0x03a90014 libdispatch.dylib`_dispatch_client_callout + 14     frame #23: 0x03a807d5 libdispatch.dylib`_dispatch_main_queue_callback_4cf + 296     frame #24: 0x03f3eaf5 corefoundation`__cfrunlooprun + 1925     frame #25: 0x03f3df44 corefoundation`cfrunlooprunspecific + 276     frame #26: 0x03f3de1b corefoundation`cfrunloopruninmode + 123     frame #27: 0x044c67e3 graphicsservices`gseventrunmodal + 88     frame #28: 0x044c6668 graphicsservices`gseventrun + 104     frame #29: 0x01aa5ffc uikit`uiapplicationmain + 1211     frame #30: 0x0000285d myapp`main(argc=1, argv=0xbffff3f4) + 141 @ main.m:16     frame #31: 0x00002785 myapp`start + 53 

turning on nszombie not give more useful debug information.

the same code used work before upgrading xcode 4.6.3 (4h1503). noted: in simulator, animation paused , clicking on resume it. weird artifact sign wrong didn't know yet.

did miss something?
if known bug, there workaround?


some research notes: similar question has been asked on so, accepted answer "fix" problem changing path animation linear translation.

my problem seems similar blog post here: http://www.blogosfera.co.uk/2013/08/exc_bad_access-while-using-coreanimation/

this isn't of answer, more of attempt give tool find more clues. hopefully, more clue chime in.

  • turn on malloc stack logging.
  • reproduce crash.
  • check registers; if $r0 or $r1 heap allocations, malloc history of said address(s).

if last event on either free, data buffer (or object) being freed prematurely. (see http://lldb.llvm.org/lldb-gdb.html information on grabbing malloc history).

now, may not that if confirms premature deallocation. tell you, if so, is race condition. unfortunately, fixing isn't possible, workaround might be. if can figure out object control might have allocated prematurely free()d buffer, ought able hold strong reference said object until animation completed.

and file bug, attaching crashing binary, please.


also, turn on malloc scribble. that'll ensure deallocated memory trashed upon deallocation, should make crash happen possibly can.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -