Replace image cause simulator to crash

Hi,

I’m using Corona Game edition and part of my game play require me to switch the image with physics body at the same location. If I do it immediately, Corona simulator crashes and Apple Bug reports open up. If I just add a 10ms delay, then it works fine.

Thanks [import]uid: 11004 topic_id: 3487 reply_id: 303487[/import]

Can you submit sample code so we can see what you are doing?

Thanks

Carlos [import]uid: 24 topic_id: 3487 reply_id: 10637[/import]

So this is the code. If you uncomment the line 38 timer.performWithDelay(...) and comment line 37 displayBlue(event) then it would work fine.

-- Physics Ballslocal cueball = display.newImage( "ball_green.png" )cueball.x = 1; cueball.y = display.contentHeight-1; cueball.alpha = 0local ballBody = { density=10, friction=0, bounce=1, radius=5 }physics.addBody( cueball, ballBody )cueball.linearDamping = 0.3cueball.isFixedRotation = truecueball.id = "cueball"cueball.isBullet = true -- force continuous collision detection, to stop really fast shots from passing through other ballslocal blue_cueball = display.newImage( "ball_blue.png" )blue_cueball.alpha = 0physics.addBody( blue_cueball, ballBody )blue_cueball.linearDamping = 0.3blue_cueball.isFixedRotation = trueblue_cueball.id = "blue_cueball"blue_cueball.isBullet = true -- force continuous collision detection, to stop really fast shots from passing through other ballslocal previousBallx, previousBally, previousBallvx, previousBallvylocal function displayBlue (event) blue_cueball.x = previousBallx; blue_cueball.y = previousBally blue_cueball.alpha = 1 blue_cueball:setLinearVelocity(previousBallvx, previousBallvy)end-- Handler for ball in going through a color poollocal function inPocket( self, event ) if ( event.phase == "began" and event.other.id == "cueball") then previousBallvx, previousBallvy = event.other:getLinearVelocity() previousBallx = event.other.x previousBally = event.other.y event.other:setLinearVelocity(0,0) event.other.parent:remove( event.other ) displayBlue(event) -- timer.performWithDelay(1, displayBlue ) endendlocal color_blog_blue = display.newImage( "color_blog_blue.png" )color_blog_blue.x = 100; color_blog_blue.y = 200physics.addBody(color_blog_blue, "static",{ radius=30, isSensor=true })color_blog_blue.id = "color_blog_blue"color_blog_blue.collision = inPocketcolor_blog_blue:addEventListener( "collision", color_blog_blue )[/code]Here's the error report:Process: Corona Simulator [42796]Path: /Applications/Corona Game Edition 2010.109/Corona Simulator.app/Contents/MacOS/Corona SimulatorIdentifier: com.anscamobile.Corona_SimulatorVersion: ??? (1.0)Code Type: X86 (Native)Parent Process: launchd [85]Date/Time: 2010-11-10 16:51:23.045 +0100OS Version: Mac OS X 10.6.4 (10F569)Report Version: 6Interval Since Last Report: 1158181 secCrashes Since Last Report: 114Per-App Interval Since Last Report: 109304 secPer-App Crashes Since Last Report: 12Anonymous UUID: 405C6903-173C-4547-96E8-D89E9E1F1876Exception Type: EXC_CRASH (SIGABRT)Exception Codes: 0x0000000000000000, 0x0000000000000000Crashed Thread: 0 Dispatch queue: com.apple.main-threadApplication Specific Information:Assertion failed: (m_world->IsLocked() == false), function SetTransform, file /Users/ansca/.hudson/jobs/Pong-DMG/workspace/platform/mac/../../external/Box2D_v2.1.2/Box2D/Box2D/Dynamics/b2Body.cpp, line 395.Thread 0 Crashed: Dispatch queue: com.apple.main-thread0 libSystem.B.dylib 0x96ddcef6 __kill + 101 libSystem.B.dylib 0x96ddcee8 kill$UNIX2003 + 322 libSystem.B.dylib 0x96e6f62d raise + 263 libSystem.B.dylib 0x96e856e4 abort + 934 libSystem.B.dylib 0x96e7228c__ pthread_markcancel + 05 ...nscamobile.Corona_Simulator 0x00082f05 b2PolygonShape::~b2PolygonShape() + 46216 ...nscamobile.Corona_Simulator 0x0002c266 0x1000 + 1767427 ...nscamobile.Corona_Simulator 0x0002ca2e 0x1000 + 1787348 ...nscamobile.Corona_Simulator 0x0003a390 0x1000 + 2343849 ...nscamobile.Corona_Simulator 0x0003a660 0x1000 + 23510410 ...nscamobile.Corona_Simulator 0x00031593 0x1000 + 19803511 ...nscamobile.Corona_Simulator 0x0006564c 0x1000 + 41121212 ...nscamobile.Corona_Simulator 0x00065777 0x1000 + 41151113 ...nscamobile.Corona_Simulator 0x0007426c 0x1000 + 47166014 ...nscamobile.Corona_Simulator 0x0006578b 0x1000 + 41153115 ...nscamobile.Corona_Simulator 0x0005addc 0x1000 + 36809216 ...nscamobile.Corona_Simulator 0x00064f93 0x1000 + 40949117 ...nscamobile.Corona_Simulator 0x00064ff0 0x1000 + 40958418 ...nscamobile.Corona_Simulator 0x0005b990 0x1000 + 37108819 ...nscamobile.Corona_Simulator 0x0002f5b3 0x1000 + 18987520 ...nscamobile.Corona_Simulator 0x0002b24a 0x1000 + 17261821 ...nscamobile.Corona_Simulator 0x00035291 0x1000 + 21364922 ...nscamobile.Corona_Simulator 0x0002a7e1 0x1000 + 16995323 ...nscamobile.Corona_Simulator 0x000570c7 0x1000 + 35245524 ...nscamobile.Corona_Simulator 0x000871ca b2CircleContact::~b2CircleContact() + 107225 ...nscamobile.Corona_Simulator 0x0008360b b2PolygonShape::~b2PolygonShape() + 641926 ...nscamobile.Corona_Simulator 0x000860d2 void b2BroadPhase::UpdatePairs(b2ContactManager*) + 883227 ...nscamobile.Corona_Simulator 0x00028973 0x1000 + 16216328 ...nscamobile.Corona_Simulator 0x0002a961 0x1000 + 17033729 com.apple.Foundation 0x9705e968 __NSFireTimer + 14130 com.apple.CoreFoundation 0x9800d70b__ CFRunLoopRun + 805931 com.apple.CoreFoundation 0x9800b094 CFRunLoopRunSpecific + 45232 com.apple.CoreFoundation 0x9800aec1 CFRunLoopRunInMode + 9733 com.apple.HIToolbox 0x98f74f9c RunCurrentEventLoopInMode + 39234 com.apple.HIToolbox 0x98f74d51 ReceiveNextEventCommon + 35435 com.apple.HIToolbox 0x98f74bd6 BlockUntilNextEventMatchingListInMode + 8136 com.apple.AppKit 0x96277a89 _DPSNextEvent + 84737 com.apple.AppKit 0x962772ca -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 15638 com.apple.AppKit 0x9623955b -[NSApplication run] + 82139 com.apple.AppKit 0x962315ed NSApplicationMain + 57440 ...nscamobile.Corona_Simulator 0x000029ce 0x1000 + 6606 [import]uid: 11004 topic_id: 3487 reply_id: 10677[/import]